javascript 如何解决 Windows 10 上的“node-gyp 重建”问题?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32457761/
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-10-28 15:18:18  来源:igfitidea点击:

How to solve 'node-gyp rebuild' issue on Windows 10?

javascriptnode.jsnpmwindows-10node-gyp

提问by Jér?me Verstrynge

As part of trying to use a node NPM dependency in a project, I get a node-gyp rebuildissue, which I have reported.

作为尝试在项目中使用节点 NPM 依赖项的一部分,我遇到了一个node-gyp rebuild问题,我已经报告了.

I am aware of the solution in this SO question, but it does not work for Windows 10 (I am on 32 bits, I don't know whether this is relevant). Windows SDK 7.1 (and others) won't install.

我知道this SO question中的解决方案,但它不适用于Windows 10(我使用32位,我不知道这是否相关)。Windows SDK 7.1(和其他)不会安装。

Does anyone have an operational solution for Windows 10?

有没有人有适用于 Windows 10 的操作解决方案?

Udpate

更新日期

After trying npm install <module name> --msvs_version=2013, I get a new error message:

尝试后npm install <module name> --msvs_version=2013,我收到一条新的错误消息:

enter image description here

在此处输入图片说明

采纳答案by mscdex

To install node addons, you need to have VC/VCExpress installed and not just the VC runtime/redistributable. Make sure it's the "Windows Desktop" edition.

要安装节点插件,您需要安装 VC/VCExpress 而不仅仅是 VC 运行时/可再发行组件。确保它是“Windows 桌面”版本。

After that, you should be able to install addons via npm (you may have to re-open any command prompts you had open before installing VCExpress though).

之后,您应该能够通过 npm 安装插件(尽管您可能需要重新打开在安装 VCExpress 之前打开的任何命令提示符)。

回答by Marco Blos

I solved this problem on windows 8 and windows 10 pro with this tutorial. I try a lot of times to solve this problem with many different solutions, but only worked for me this
I notice that i didn't use nodist to control the node version like this tutorial, I use NVM and worked fine, i don't test this tutorial with nodist. I used node 5.2.0.

我使用本教程在 windows 8 和 windows 10 pro 上解决了这个问题。我尝试了很多次使用许多不同的解决方案来解决这个问题,但只对我
有用我注意到我没有像本教程那样使用 nodist 来控制节点版本,我使用 NVM 并且工作正常,我没有使用 nodist 测试本教程。我使用了节点 5.2.0。

Edit:

编辑:

Following the suggested by @prasun, the steps in correct order:

按照@prasun 的建议,步骤顺序正确:

  • Download and install Git SCM from HERE
  • Download Visual Studio Community HEREand install a Custom Installation, selecting ONLYthe following packages: VISUAL C++, PYTHON TOOLS FOR VISUAL STUDIOand MICROSOFT WEB DEVELOPER TOOLS
  • Download and install Python 2.7.x from HERE
  • Register a Environment Variable with name: GYP_MSVS_VERSION with this value: 2015.
  • 这里下载并安装 Git SCM
  • 此处下载 Visual Studio Community并安装自定义安装,选择以下软件包:VISUAL C++PYTHON TOOLS FOR VISUAL STUDIOMICROSOFT WEB DEVELOPER TOOLS
  • 这里下载并安装 Python 2.7.x
  • 注册一个名称为:GYP_MSVS_VERSION 的环境变量,其值为:2015。

This is the only steps work for me in windows 8.1 and windows 10.

这是在 Windows 8.1 和 Windows 10 中对我有用的唯一步骤。

回答by quidkid

This worked for me:

这对我有用:

npm install --global --production windows-build-tools