node.js - Visual Studio Online 中的 npm 安装失败

标签 node.js visual-studio npm continuous-integration azure-devops

我有一个 Web 应用程序,前端使用 Angular 构建,后端使用 MVC、WebApi 构建。我正在致力于在 Visual Studio Online 上创建 CI 环境。现在,npm 安装和运行 grunt 任务由 .cmd 文件处理,并包含在 Visual Studio Web 项目的构建过程中。

当我在 VSO 中添加构建步骤时,我已将构建步骤分离到 NuGet 安装、解决方案构建、npm 安装、grunt 任务运行等中(我也从项目中删除了 .cmd 文件的执行) )。

但是当 npm install 步骤发生时,它失败并出现以下错误..

******************************************************************************
Starting task: npm install
******************************************************************************
Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\tasks\NpmInstall\0.1.3\NpmInstall.ps1
C:\Program Files\nodejs\npm.cmd  install
npm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="98ffeaedf6ecb5c0c0c0c0c0c0c0b5d1fcfdf6ecf1ece1d8a8b6a9b6a8" rel="noreferrer noopener nofollow">[email protected]</a> No description
npm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a1c6d3d4cfd58cf9f9f9f9f9f9f98ce8c5c4cfd5c8d5d8e1918f908f91" rel="noreferrer noopener nofollow">[email protected]</a> No README data
npm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="127560677c663f4a4a4a4a4a4a4a3f5b76777c667b666b52223c233c22" rel="noreferrer noopener nofollow">[email protected]</a> No license field.
npm WARN peerDependencies The peer dependency tslint@^2.0.1 included from grunt-tslint will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN optional dep failed, continuing <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a4c2d7c1d2c1cad0d7e4958a948a94" rel="noreferrer noopener nofollow">[email protected]</a>
> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ddabe5f0adafb2bbb4b1b8af9de8f3eff3ecef" rel="noreferrer noopener nofollow">[email protected]</a> preinstall C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-profiler
>  
> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d2a4eaffb6b7b0a7b592e2fce6fce4" rel="noreferrer noopener nofollow">[email protected]</a> preinstall C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug
>  
npm WARN optional dep failed, continuing <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="593d3c3f382c352d743b2b362e2a3c2b74303d19687769776b" rel="noreferrer noopener nofollow">[email protected]</a>
npm WARN engine <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dea6b3b2bcabb7b2babbac9eecf0ecf0ef" rel="noreferrer noopener nofollow">[email protected]</a>: wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"0.12.7","npm":"2.11.3"})
> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3351465555564146475a5f73021d021d03" rel="noreferrer noopener nofollow">[email protected]</a> install C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild
C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\ws\node_modules\bufferutil>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild ) 
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  bufferutil.cc
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\exception(361): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc [C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\ws\node_modules\bufferutil\build\bufferutil.vcxproj]
     Creating library C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\ws\node_modules\bufferutil\build\Release\bufferutil.lib and object C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\ws\node_modules\bufferutil\build\Release\bufferutil.exp
  Generating code
  Finished generating code
  bufferutil.vcxproj -> C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\ws\node_modules\bufferutil\build\Release\\bufferutil.node
> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="572223317a6f7a21363b3e33362332176679667967" rel="noreferrer noopener nofollow">[email protected]</a> install C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\ws\node_modules\utf-8-validate
> node-gyp rebuild
C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\ws\node_modules\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild ) 
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  validation.cc
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\exception(361): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc [C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\ws\node_modules\utf-8-validate\build\validation.vcxproj]
     Creating library C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\ws\node_modules\utf-8-validate\build\Release\validation.lib and object C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\ws\node_modules\utf-8-validate\build\Release\validation.exp
  Generating code
  Finished generating code
  validation.vcxproj -> C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\ws\node_modules\utf-8-validate\build\Release\\validation.node
> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8afcb2a7faf8e5ece3e6eff8cabfa4b8a4bbb8" rel="noreferrer noopener nofollow">[email protected]</a> install C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-profiler
> node-pre-gyp install --fallback-to-build
 Success: "C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-profiler\build\profiler\v5.2.12\node-v14-win32-x64\profiler.node" is installed via remote
> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e096d8cd8485829587a0d0ced4ced6" rel="noreferrer noopener nofollow">[email protected]</a> install C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug
> node-pre-gyp install --fallback-to-build
C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean )  else (node  clean ) 
C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build "--module=C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\debug\v0.4.6\node-v14-win32-x64\debug.node" --module_name=debug "--module_path=C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\debug\v0.4.6\node-v14-win32-x64" )  else (node  configure --fallback-to-build "--module=C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\debug\...
Warning: Missing input files:
C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\..\..\..\..\..\..\..\..\..\..\..\..\..\..\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c
C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" build --fallback-to-build "--module=C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\debug\v0.4.6\node-v14-win32-x64\debug.node" --module_name=debug "--module_path=C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\debug\v0.4.6\node-v14-win32-x64" )  else (node  build --fallback-to-build "--module=C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\debug\v0.4.6\n...
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  debug.cc
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\exception(361): warning C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc [C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\debug.vcxproj]
  win_delay_load_hook.c
c1 : fatal error C1083: Cannot open source file: '..\..\..\..\..\..\..\..\..\..\..\..\..\..\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c': No such file or directory [C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\debug.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\a\\02e68ad0\\XXXX XXXXXX\\Source\\XXXXXXX.Identity\\XXXXXXX.Identity.Web\\_ci\\node_modules\\grunt-debug-task\\node_modules\\node-inspector\\node_modules\\v8-debug\\build\\debug\\v0.4.6\\node-v14-win32-x64\\debug.node" "--module_name=debug" "--module_path=C:\\a\\02e68ad0\\XXXX XXXXXX\\Source\\XXXXXXX.Identity\\XXXXXXX.Identity.Web\\_ci\\node_modules\\grunt-debug-task\\node_modules\\node-inspector\\node_modules\\v8-debug\\build\\debug\\v0.4.6\\node-v14-win32-x64"
gyp ERR! cwd C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\debug\v0.4.6\node-v14-win32-x64\debug.node --module_name=debug --module_path=C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\debug\v0.4.6\node-v14-win32-x64' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:110:17)
node-pre-gyp ERR! stack at maybeClose (child_process.js:1015:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
node-pre-gyp ERR! System Windows_NT 6.3.9600
node-pre-gyp ERR! command "node" "C:\\a\\02e68ad0\\XXXX XXXXXX\\Source\\XXXXXXX.Identity\\XXXXXXX.Identity.Web\\_ci\\node_modules\\grunt-debug-task\\node_modules\\node-inspector\\node_modules\\v8-debug\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug
node-pre-gyp ERR! node -v v0.12.7
node-pre-gyp ERR! node-pre-gyp -v v0.6.11
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\debug\v0.4.6\node-v14-win32-x64\debug.node --module_name=debug --module_path=C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\node_modules\grunt-debug-task\node_modules\node-inspector\node_modules\v8-debug\build\debug\v0.4.6\node-v14-win32-x64' (1)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4137796c252423342601716f756f77" rel="noreferrer noopener nofollow">[email protected]</a> install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bdcb8590d9d8dfc8dafd8d9389938b" rel="noreferrer noopener nofollow">[email protected]</a> install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the v8-debug package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls v8-debug
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\a\02e68ad0\XXXX XXXXXX\Source\XXXXXXX.Identity\XXXXXXX.Identity.Web\_ci\npm-debug.log
Unexpected exit code 1 returned from tool npm.cmd

我在使用 .cmd 脚本时也遇到了这个问题。我做了 npm 更新,效果很好。在执行 npm install

之前,我在脚本上执行了以下命令
npm install npm@latest
npm update --depth=0 -g

这让它工作了。但当我在 VSO 中使用构建步骤时,我无法执行此操作。为什么会出现此错误以及如何修复此错误。另外,我如何执行 npm 更新步骤 VSO 构建步骤?

最佳答案

您需要添加一个 npm install 构建步骤。默认情况下,工作目录默认为项目的根目录。并在 Arguments 字段中指定 npm install 参数。喜欢:

enter image description here

关于node.js - Visual Studio Online 中的 npm 安装失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32777331/

相关文章:

node.js - Keystone.js 管理 UI - 表单中没有字段

c# - PublishSingleFile 不生成单个可执行文件

linux - Visual Studio 更改已编辑文件的所有权

node.js - 为什么 'npm run build' 在开发服务器上花费 >30 分钟而在本地花费不到一分钟?

javascript - 安装 eslint 作为扩展和安装为 npm 包有什么区别?

javascript - 将 JavaScript 对象转换为数组以插入关系数据库

javascript - 将视频 blob 保存到文件系统 electron/node js

c# - VS2013 Intellisense 不断停止工作

android - Cordova Build Android 失败,退出代码为 ENOENT

node.js - fs.writeFile() 是否处理 Nodejs 中的竞争条件?