首页 > 解决方案 > 运行“npm install”:Node-gyp 错误 - MSBUILD.exe 失败,退出代码:1

问题描述

我正在运行npm install以在 Windows 上安装我的项目中的所有包。

然后我收到有关 MSBUILD.exe 的错误消息:

gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.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:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\
node-gyp.js" "build" "--fallback-to-build" "--library=static_library" "--module=C:\\Users\\masso\\Desktop\\Stage 2019\\maev2-front-
master\\node_modules\\grpc\\src\\node\\extension_binary\\node-v72-win32-x64-unknown\\grpc_node.node" "--module_name=grpc_node" "--m
odule_path=C:\\Users\\masso\\Desktop\\Stage 2019\\maev2-front-master\\node_modules\\grpc\\src\\node\\extension_binary\\node-v72-win
32-x64-unknown" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd C:\Users\masso\Desktop\Stage 2019\maev2-front-master\node_modules\grpc
gyp ERR! node -v v12.14.0
gyp ERR! node-gyp -v v5.0.7
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_mo
dules\node-gyp\bin\node-gyp.js build --fallback-to-build --library=static_library --module=C:\Users\masso\Desktop\Stage 2019\maev2-
front-master\node_modules\grpc\src\node\extension_binary\node-v72-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module
_path=C:\Users\masso\Desktop\Stage 2019\maev2-front-master\node_modules\grpc\src\node\extension_binary\node-v72-win32-x64-unknown -
-napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\masso\Desktop\Stage 2019\maev2-front-master\node_modules\grpc\nod
e_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Windows_NT 10.0.18362
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\masso\\Desktop\\Stage 2019\\maev2-front-master\\node_mo
dules\\grpc\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd C:\Users\masso\Desktop\Stage 2019\maev2-front-master\node_modules\grpc
node-pre-gyp ERR! node -v v12.14.0
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok```

I have try many things like installing package `windows-build-tools`, running `npm install` with --no-optional option and some others I don't remember. Nothing actualy worked.

If someone could try to help him please.

Kind regards.

标签: node.jswindowsnpmmsbuild

解决方案


卸载节点并安装低于 Node v11.15 的节点版本,它是 node-gyp 工作的最新版本!!!

例如,我使用 v 11.14


推荐阅读