Python 吉普错误!堆栈错误:`C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` 失败,退出代码:1

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32964144/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 12:33:12  来源:igfitidea点击:

gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` failed with exit code: 1

pythonc++node.jsmsbuild

提问by SELVA

When I run npm install, I face the following error. I am not able to find the problem.

当我运行时npm install,我面临以下错误。我找不到问题所在。

I need some help in finding this issue.

我需要一些帮助来找到这个问题。

d:\testing\node-sample-module\node_modules\ffi\node_modules\ref\node_modules\nan\nan_implementation_pre_12_inl.h(112): error C2668: 'v8::FunctionTemplate::New' :  ambiguous call to overloaded function [d:\TESTING\node-sample-module\node_modules \ffi\node_modules\ref\build\binding.vcxproj]
C:\Users\SELVA\.nw-gyp
npm install --msvs_version=2013
.8.5\deps\v8\include\v8.h(3344): could be 'v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::FunctionCallback,v8::Handle<v8::Value>,v8::Handle<v8::Signature>,int)' C:\Users\SELVA\.nw-gyp##代码##.8.5\deps\v8\include\v8.h(3343): or v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::InvocationCallback,v8::Handle<v8::Value>,v8::Handle<v8::Signature>,int)' while trying to match the argument list '(int, v8::Local<v8::Value>, v8::Local<v8::Signature>)' gyp ERR! build error gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild.0\bin\msbuild.exe` failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (c:\Users\SELVA\AppData\Roaming\npm\node_modules\nw-gyp\lib\build.js:267:23) gyp ERR! stack at ChildProcess.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:820:12) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "node" "c:\Users\SELVA\AppData\Roaming\npm\node_modules\nw-gyp\bin\nw-gyp.js" "clean" "configure" "--target=0.8.5" "build" "--arch=ia32" gyp ERR! cwd d:\TESTING\node-sample-module\node_modules\ffi\node_modules\ref gyp ERR! node -v v0.10.35 gyp ERR! nw-gyp -v v0.12.4 gyp ERR! not ok

FYI, I am using windows 7 machine.

仅供参考,我使用的是 Windows 7 机器。

Also, have the following installed:

此外,请安装以下内容:

  • Visual C++ Redistributable 2013 (32 bit)

  • Python 2.7.3 (env variable set to path/python.exe)

  • Visual studio Express 2013

  • .Net framework 4.5 SDK

  • Visual C++ Redistributable 2013(32 位)

  • Python 2.7.3(环境变量设置为 path/python.exe)

  • Visual Studio Express 2013

  • .Net 框架 4.5 SDK

Thanks in Advance.

提前致谢。

回答by Brian Frisch

Update:

更新:

A new package will do all of this for us now.

现在,一个新的软件包将为我们完成所有这些工作。

Make sure you have the sufficient permissions by running:

通过运行确保您有足够的权限:

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force

then run:

然后运行:

npm install -g windows-build-tools

npm install -g windows-build-tools

wait for it to install and then run:

等待它安装,然后运行:

window-build-tools

window-build-tools

and everything should be in its finest order.

一切都应该是最好的秩序。



Old answer:

旧答案:

I just went through some of the same issues as you. I spun up a fresh installation of Windows 8.1 in Hyper-V, went through the installation process and jotted things down a long the way. It seems that you have all the necessary tools installed.

我刚刚经历了一些和你一样的问题。我在 Hyper-V 中启动了 Windows 8.1 的全新安装,完成了安装过程并记下了很长一段路。您似乎已经安装了所有必要的工具。

I think the only think you might be missing (not being entirely sure though) could be setting the msvs_version-flag when running npm install- so try seeing if this helps:

我认为您可能遗漏的唯一想法(虽然不完全确定)可能是msvs_version在运行时设置-flag npm install- 所以尝试看看这是否有帮助:

##代码##

Now that I've done all these notes I might as well put them here, so people that experience the same kind of problems might find some help.

既然我已经完成了所有这些笔记,我不妨将它们放在这里,以便遇到相同问题的人可能会找到一些帮助。

My recipe on a freshly installed machine:

我在新安装的机器上的食谱:

1) Install Node.js

1)安装 Node.js

2) Install git

2)安装git

  • CLI commands should be executed with administrator rights
  • Select "Use Git and optional Unix tools from the Windows Command Prompt

    • git-add-to-path
  • CLI 命令应以管理员权限执行
  • 选择“从 Windows 命令提示符中使用 Git 和可选的 Unix 工具

    • git-add-to-path

3) Upgrade npm to npm 3.x.x(optional step)

3)将 npm 升级到 npm 3.xx(可选步骤)

Even though you've just installed Node.js it doesn't necessarily mean you have npm in version 3.

即使您刚刚安装了 Node.js,也并不一定意味着您在版本 3 中安装了 npm。

  • CLI commands should be executed with administrator rights
  • Run npm install -g npm-windows-upgradein the command line interface.
  • Run Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Forcein the command line interface
  • Run npm-windows-upgradein the command line interface
  • Select the newest version and let it install
  • When it finishes the install run npm --versionand make sure it responds with something like 3.x.x
  • CLI 命令应以管理员权限执行
  • npm install -g npm-windows-upgrade在命令行界面中运行。
  • Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force在命令行界面中运行
  • npm-windows-upgrade在命令行界面中运行
  • 选择最新版本并安装
  • 当它完成安装运行npm --version并确保它响应类似3.x.x

4) Install Python 2.7.x

4)安装 Python 2.7.x

  • Go to https://www.python.org/downloads
  • Click the button to download Python 2.7.x
  • Run the installer.
  • Select Install for all users- click next.
  • Select to install in C:\Python27- click next

    • python-location
  • Be sure to select Will be installed on local hard drivein Add python.exe to Path- click next

    • python-add-to-path-01

    • python-add-to-path-02

    • python-add-to-path-03

  • Finish up the installation

  • 转到https://www.python.org/downloads
  • 点击按钮下载Python 2.7.x
  • 运行安装程序。
  • 选择Install for all users- 单击下一步。
  • 选择安装在C:\Python27-点击下一步

    • 蟒蛇位置
  • 一定要选择Will be installed on local hard drivein Add python.exe to Path- 点击next

    • python-add-to-path-01

    • python-add-to-path-02

    • python-add-to-path-03

  • 完成安装

5) Install Visual Studio Express 2013 for Windows Desktop with Update 4

5)安装 Visual Studio Express 2013 for Windows Desktop with Update 4

Even if you have another version of Visual Studio installed on your system do install this as well.

即使您的系统上安装了另一个版本的 Visual Studio,也要安装它。

  • Go to http://www.microsoft.com/en-gb/download/details.aspx?id=44914
  • Select Englishor some other available language and click Download
  • Check wdexpress_full.exeand click "Next"
  • Run the file downloaded. Begin the installation.
  • If you're unable to start the installation, it means you already have the necessary tools for this step. Abort the installation.
  • 转到http://www.microsoft.com/en-gb/download/details.aspx?id=44914
  • 选择English或其他一些可用语言并单击Download
  • 检查wdexpress_full.exe并单击“下一步”
  • 运行下载的文件。开始安装。
  • 如果您无法开始安装,则表示您已经拥有执行此步骤所需的工具。中止安装。

Now run npm install --msvs_version=2013and you should be able to reach the end without node-gyp throwing errors.

现在运行npm install --msvs_version=2013,您应该能够到达终点而不会出现 node-gyp 抛出错误。

回答by jarrettyeo

For me on Windows 10 and Node 13, I had to uninstall Visual Studio and Build Tools, and uninstall Node 13. Then, I deleted npm and npm-cache from Roaming, before reinstalling Node 11.6 and choosing to install Chocolately. It worked for me thereafter.

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