npm install that requires node-gyp fails on Windows

前提是你 提交于 2019-11-29 21:03:36
Manuel Beaudru

The answer below stands for a manual installation, but there is a much simpler way : the automatic install.

Open Powershell as admin and run npm install -g windows-build-tools.

The install takes time but it worked like a charm for me !

Marek Lisý

I found this brilliant solution on GitHub:

  1. Your OS MUST be Windows
  2. Check that python is in your path by writting python --version in the console. If not then
  3. Download python 2.7 (I recommend chocolatey (choco install python2 -y)) and add python.exe to your PATH variable.
  4. Aren't you on Windows 7? Skip 5 and 6.
  5. Check that you have .NET 4.5.1+ installed. If not then
  6. Download and install .NET 4.5.1 (.NET 4.5.2 will also work just fine)
  7. Download Microsoft Visual C++ Build Tools 2015 Technical Preview
  8. Use custom install. Install the Windows 8.1 SDK if you haven't already. Apparently, it doesn't matter what OS you're on. You just need the Windows 8.1 SDK.
  9. Set the npm config variable msvs_version to 2015: npm config -g set msvs_version 2015
  10. Do npm i in what-ever project with node-gyp as a dependency without seeing weird error messages

My nightmares are gone!

After wasting many hours over several days trying to install ZeroMQ on Winturds 7 and 10 (including the ridiculous and completely useless installation of .NET and Visual Studio), it was actually easier to create an Ubuntu USB boot disc and install node and ZeroMQ. Now I can actually do productive work.

I was having this issue when updating from an older version of node to node v12. There was a particular issue with bcrypt library. I just uninstalled v12 and installed v10 and everything worked.

I couldn't find my solution anywhere else, so thought I'd share.

Running node v10.16.3 on Windows 10

Install windows-build-tools -

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

Set the python path explicitly in C:\Users[your username].npmrc - In my case, this is like so:

python=c:\users\akeel\.windows-build-tools\python27\python
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!