在VSTS中,CI中的Npm失败,返回码4294963238

时间:2018-07-07 21:19:18

标签: azure-devops azure-pipelines

我正在尝试为角度应用程序在VSTS上配置CI / CD。但是由于上述错误,构建失败。 因此,有两个npm任务;

  • npm安装-成功执行
  • npm运行脚本构建-此操作失败

    这是第二项任务的完整日志:

    2018-07-07T00:23:02.3521053Z ## [section]开始:npm run build

2018-07-07T00:23:02.3525327Z

2018-07-07T00:23:02.3525444Z Task         : npm
2018-07-07T00:23:02.3525589Z Description  : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Package Management.
2018-07-07T00:23:02.3525700Z Version      : 1.0.17
2018-07-07T00:23:02.3525777Z Author       : Microsoft Corporation
2018-07-07T00:23:02.3525891Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613746)
2018-07-07T00:23:02.3525989Z ==============================================================================
2018-07-07T00:23:02.8106804Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" --version"
2018-07-07T00:23:03.8647145Z 5.6.0
2018-07-07T00:23:05.7712361Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" config list"
2018-07-07T00:23:06.7257653Z ; cli configs
2018-07-07T00:23:06.7258787Z metrics-registry = "https://registry.npmjs.org/"
2018-07-07T00:23:06.7260115Z scope = ""
2018-07-07T00:23:06.7263255Z user-agent = "npm/5.6.0 node/v8.11.3 win32 x64"
2018-07-07T00:23:06.7264469Z 
2018-07-07T00:23:06.7264814Z ; environment configs
2018-07-07T00:23:06.7265449Z cache = "C:\\npm\\cache"
2018-07-07T00:23:06.7266275Z prefix = "C:\\npm\\prefix"
2018-07-07T00:23:06.7266951Z userconfig = "D:\\a\\3\\npm\\1.npmrc"
2018-07-07T00:23:06.7268494Z 
2018-07-07T00:23:06.7269010Z ; builtin config undefined
2018-07-07T00:23:06.7307698Z 
2018-07-07T00:23:06.7309592Z ; node bin location = C:\Program Files\nodejs\node.exe
2018-07-07T00:23:06.7309872Z ; cwd = D:\a\3\s
2018-07-07T00:23:06.7310021Z ; HOME = C:\Users\VssAdministrator
2018-07-07T00:23:06.7310173Z ; "npm config ls -l" to show all defaults.
2018-07-07T00:23:06.7310307Z 
2018-07-07T00:23:06.7311709Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" run-script build"
2018-07-07T00:23:07.7555197Z npm ERR! path D:\a\3\s\package.json
2018-07-07T00:23:07.7555647Z npm ERR! code ENOENT
2018-07-07T00:23:07.7555859Z npm ERR! errno -4058
2018-07-07T00:23:07.7556046Z npm ERR! syscall open
2018-07-07T00:23:07.7556221Z npm ERR! enoent ENOENT: no such file or directory, open 'D:\a\3\s\package.json'
2018-07-07T00:23:07.7556406Z npm ERR! enoent This is related to npm not being able to find a file.
2018-07-07T00:23:07.7556583Z npm ERR! enoent 
2018-07-07T00:23:07.7556696Z 
2018-07-07T00:23:07.7556849Z npm ERR! A complete log of this run can be found in:
2018-07-07T00:23:07.7557018Z npm ERR!     C:\npm\cache\_logs\2018-07-07T00_23_07_693Z-debug.log
2018-07-07T00:23:07.8410994Z Found npm debug log, make sure the path matches with the one in npm's output: C:\npm\cache\_logs\2018-07-07T00_23_07_693Z-debug.log
2018-07-07T00:23:07.8411205Z 0 info it worked if it ends with ok
2018-07-07T00:23:07.8411317Z 1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
2018-07-07T00:23:07.8411464Z 1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
2018-07-07T00:23:07.8411575Z 1 verbose cli   'run-script',
2018-07-07T00:23:07.8411667Z 1 verbose cli   'build' ]
2018-07-07T00:23:07.8412548Z 2 info using npm@5.6.0
2018-07-07T00:23:07.8412687Z 3 info using node@v8.11.3
2018-07-07T00:23:07.8412805Z 4 verbose stack Error: ENOENT: no such file or directory, open 'D:\a\3\s\package.json'
2018-07-07T00:23:07.8412915Z 5 verbose cwd D:\a\3\s
2018-07-07T00:23:07.8413007Z 6 verbose Windows_NT 10.0.14393
2018-07-07T00:23:07.8413155Z 7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run-script" "build"
2018-07-07T00:23:07.8413285Z 8 verbose node v8.11.3
2018-07-07T00:23:07.8413373Z 9 verbose npm  v5.6.0
2018-07-07T00:23:07.8413474Z 10 error path D:\a\3\s\package.json
2018-07-07T00:23:07.8413567Z 11 error code ENOENT
2018-07-07T00:23:07.8413654Z 12 error errno -4058
2018-07-07T00:23:07.8413740Z 13 error syscall open
2018-07-07T00:23:07.8414697Z 14 error enoent ENOENT: no such file or directory, open 'D:\a\3\s\package.json'
2018-07-07T00:23:07.8414808Z 15 error enoent This is related to npm not being able to find a file.
2018-07-07T00:23:07.8414912Z 16 verbose exit [ -4058, true ]
2018-07-07T00:23:07.8414968Z 
2018-07-07T00:23:07.8459901Z ##[error]Error: Npm failed with return code: 4294963238
2018-07-07T00:23:07.8486587Z ##[section]Finishing: npm run build

这是该日志的屏幕截图:

screenshot

我看过this文章,但他们也说这是CI中的问题。如果有人遇到过类似的问题并取得了成功,请让我们

2 个答案:

答案 0 :(得分:0)

您的文件可能位于$(System.DefaultWorkingDirectory)/中,您应该将其用作“带有package.json的工作文件夹”。

到目前为止,我已经发现Azure管道具有两个“特殊” /预定义目录:$(System.DefaultWorkingDirectory)$(Build.ArtifactStagingDirectory),它们的值都设置为env参数。

尝试使用脚本步骤打印出./$(System.DefaultWorkingDirectory)/$(Build.ArtifactStagingDirectory)/的内容;它将帮助您找到文件并确定应在何处运行命令。

答案 1 :(得分:0)

在构建步骤中,我的Azure DevOps构建管道中也遇到了类似的错误。

  

2019-01-07T10:14:37.3232741Z 24详细出口[1,正确]   2019-01-07T10:14:37.3232816Z 2019-01-07T10:14:37.3286590Z

     

[错误]错误:Npm失败,返回码:1 2019-01-07T10:14:37.3309955Z ## [section]完成:npm build

我的问题是我已将代理程序池设置为“托管”而不是“托管VS2017”。进行如下更改后,构建成功。

enter image description here

希望有帮助。