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

sej*_*jal 14 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
Run Code Online (Sandbox Code Playgroud)

在许多解决方案中,我尝试npm install node-gyp或卸载或重新安装它,但我遇到了同样的错误。

也试试这个步骤:

  • 安装最新版本的 Python(可能不相关)和“Microsoft Visual C++ Redistributable for Visual Studio 2017”,当然还有 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、vc++ 构建工具、visual studio 2017 和所有必需组件的 python。

我正在寻找过去 2 周的解决方案,请建议我正确的答案

Shu*_*ari 24

  1. 跑: npm cache clean --force
  2. 删除 node_modules
  3. 删除 packagelock.json 和 yarn.lock(如果有)
  4. 跑: npm install

  • 我遵循相同的步骤但遇到相同的错误。我的日志放入一个文件中 (2认同)
  • 删除 ~/.node-gyp 文件夹,然后删除 ~/.npmrc 文件。重新启动服务器并在项目文件夹中重新运行 npm install **并请检查服务器节点版本 package.json 文件而不是本地环境正在运行的版本。因此,请检查您在本地运行的内容:** (2认同)
  • 请参考这个,它将帮助您[ /sf/ask/3646251381/ ] (2认同)

jar*_*yeo 5

这些答案在 Windows 10 和 Node 13 上都不适合我。我必须卸载 Visual Studio 和 Build Tools,并卸载 Node 13。然后,我从 Roaming 中删除了 npm 和 npm-cache,然后重新安装 Node 11.6 并选择安装 Chocolately 。此后它对我有用。

  • 我在 Win 10 上遇到了同样的问题 - 问题又是节点的版本。我安装了适用于 Windows 的节点版本管理器:https://github.com/coreybutler/nvm-windows/releases 然后我安装了 v.10(因为这是针对 Ang7 项目的,在此之前我安装了 v.12): nvm install 10 nvm use 10.0.0 这解决了问题。如果您在多个存储库中工作,则可以使用管理器快速切换节点版本。 (2认同)
  • 是的,这对我有用,显然当我勾选了要求安装chocolaty和其他C++库的复选框时,它下载了缺少的任何东西,并且我能够执行“npm install” (2认同)