如何解决azure DevOps中的npm错误代码:254?

如何解决azure DevOps中的npm错误代码:254?,npm,azure-devops,yaml,npm-install,cypress,Npm,Azure Devops,Yaml,Npm Install,Cypress,当我尝试将我的cypress测试(通过nodejs和.yml)包括到azure DevOps时,我得到以下错误: Npm失败,返回代码:254 这意味着什么?我如何解决这个问题 我的完整日志如下: Starting: Npm ============================================================================== Task : npm Description : Install and publish npm

当我尝试将我的cypress测试(通过nodejs和.yml)包括到azure DevOps时,我得到以下错误:

Npm失败,返回代码:254

这意味着什么?我如何解决这个问题

我的完整日志如下:

Starting: Npm
==============================================================================
Task         : npm
Description  : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
Version      : 1.174.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
==============================================================================
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
/opt/hostedtoolcache/node/10.22.0/x64/bin/npm --version
6.14.6
/opt/hostedtoolcache/node/10.22.0/x64/bin/npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.6 node/v10.22.0 linux x64"

; environment configs
userconfig = "/home/vsts/work/1/npm/2560.npmrc"

; node bin location = /opt/hostedtoolcache/node/10.22.0/x64/bin/node
; cwd = /home/vsts/work/1/s
; HOME = /home/vsts
; "npm config ls -l" to show all defaults.

/opt/hostedtoolcache/node/10.22.0/x64/bin/npm run test
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/vsts/work/package.json
npm ERR! errno -2

我使用以下YAML: 为了创建这个yaml,我使用了一个将Cypress持续集成到azure devops的教程

# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
    npm install
  displayName: 'npm install'

- task: Npm@1
  inputs:
    command: 'custom'
    customCommand: 'run test'
  continueOnError: true

- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'JUnit'
    testResultsFiles: '*.xml'
    searchFolder: '$(System.DefaultWorkingDirectory)/cypress/reports/junit'
    mergeTestResults: true
    testRunTitle: 'Publish Test Results'

根据日志中的错误消息:
enoint:没有这样的文件或目录,打开“/home/vsts/work/package.json”
,npm找不到您的package.json文件。请检查package.json所在的文件夹。例如:

My package.json位于web/app文件夹中。我需要将此文件夹设置为npm任务中的工作文件夹

以下是我的npm任务的配置:

- task: Npm@1
  inputs:
    command: 'custom'
    workingDir: '$(Build.SourcesDirectory)/web/app'
    customCommand: 'run test'
  continueOnError: true

您可以发布错误的完整日志吗?您还可以从发生错误的YAML配置中添加一个代码段吗?npm似乎在错误的目录中查找
package.json
。管道源代码(我假设包括您的
包.json
文件)默认应位于
/home/vsts/work/id/s
文件夹中,但根据错误日志判断,npm正在
/home/vsts/work
中查找该文件。我添加了yaml。但是如何检查package.json是否位于azure中的正确位置?@ABC123是否有关于此票证的更新?如果答案能给你一些帮助,请随时告诉我。只是提醒一下。@KevinLu MSFT它仍然处于打开状态。我更改了package.json文件的路径,但得到了相同的错误code@ABC123如果我的工作文件夹不正确,我可以在我这边复制相同的错误消息。更换后效果良好。如果您仍然存在此问题,您可以分享以下内容吗?1.npm任务的配置。2.构建日志。3.package.json在repo中的位置。谢谢。my package.json的位置是my repo my npm设置中的文件夹/cypressio:
-任务:Npm@1输入:command:'custom'customCommand:'runtest'continueOnError:true
根据包的位置。json,npm任务的正确配置应为:-任务:Npm@1输入:命令:“自定义”workingDir:“$(Build.SourcesDirectory)/cypressio”自定义命令:“运行测试”continueOnError:truenow我收到以下错误:详细信息作业1个错误,1个警告错误:eNot:没有这样的文件或目录,stat'/home/vsts/work/1/s/cypressio'