错误:`C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ BuildTools \ MSBuild \ 15.0 \ Bin \ MSBuild.exe`失败,退出代码:1

时间:2019-02-05 10:56:31

标签: node.js npm npm-install

我正在尝试使用npm install命令安装所有依赖项,但是在安装过程中却出现如下错误:

ling source file ..\src\threaded_callback_invokation.cc)
c:\applatest\applatest\node_modules\nan\nan.h(1478): warning C4996: 'node::MakeCallback': was declared deprecated (comp
iling source file ..\src\threaded_callback_invokation.cc) [C:\appLatest\appLatest\node_modules\voicemeeter\node_modules
\ffi\build\ffi_bindings.vcxproj]
  c:\users\alliancetek\.node-gyp\10.15.0\include\node\node.h(176): note: see declaration of 'node::MakeCallback' (compi
  ling source file ..\src\threaded_callback_invokation.cc)
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\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:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\appLatest\appLatest\node_modules\voicemeeter\node_modules\ffi
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-linux@1.3.1 (node_modules\7zip-bin-linux):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 7zip-bin-linux@1.3.1: wanted {"os":"linux","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-mac@1.0.1 (node_modules\7zip-bin-mac):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 7zip-bin-mac@1.0.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ffi@2.2.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ffi@2.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\alliancetek\AppData\Roaming\npm-cache\_logs\2019-02-05T10_40_31_378Z-debug.log

在许多解决方案中,我都尝试过npm install node-gyp或再次将其卸载或安装,但是我遇到了同样的错误。

也可以尝试以下步骤:

  • 安装最新版本的Python(可能不相关)和“ Visual Studio 2017的Microsoft Visual C ++可再发行组件”,当然还有Node.js和NPM;
  • 以管理员身份: $ cd“ C:\ Program Files \ nodejs \ node_modules \ npm” $ npm install node-gyp
  • $ npm config set msvs_version 2015 --global 请注意,我有VS 2017,但将其配置为2017版本将无法使用。不知道为什么。
  • 以管理员身份: $ npm install -g node-sass 最后,最后检查: $ node-sass -v

并尝试使用npm install --production windows-build-tools,但任何选择都没有结果。

尝试了所有解决方案,但没有任何解决方法。我已经安装了带有2.7.15的python,vc ++构建工具,Visual Studio 2017和所有必需的组件。

我正在寻找最近2周的解决方案,请为我建议正确的答案

5 个答案:

答案 0 :(得分:1)

  • 运行 npm install --production windows-build-tools 可能需要更长的时间来安装,为我的朋友工作
<块引用>

  • 重新安装 nodeJs 对我有用

答案 1 :(得分:0)

  1. 运行:-npm缓存清理--force
  2. 删除node_modules
  3. 删除packagelock.json和yarn.lock(如果有)
  4. 运行:-npm install

答案 2 :(得分:0)

这些答案都无法在Windows 10和Node 13上工作。我必须卸载Visual Studio和Build Tools,再卸载Node13。然后,在重新安装Node 11.6并选择之前,我从漫游中删除了npm和npm-cache。安装Chocolately。此后对我有用。

答案 3 :(得分:0)

您可以尝试将 Node.js 降级到旧版本,我使用的是 v14.16.1LTS 版本。 切换到 v10.24.1 后,它起作用了。

要更改您的节点版本,请检查 How to change to an older version of Node.js

记得先删除您的 node_modules 文件夹和 package-lock.jsonyarn.lock

您也可以尝试从 yarn 切换到 npm 或从 npm 切换到 yarn。

答案 4 :(得分:-1)

在具有管理员权限的cmd中运行以下命令:

npm install --global --production windows-build-tools --vs2017
相关问题