POST POST

SEP
26
2016

How to Fix node-gyp Error on Windows

ORIGINALLY POSTED TO: https://blog.davidwesst.com/2016/09/How-to-Fix-node-gyp-Errors-on-Windows/

I hit this problem once or twice a year and always seem to forget how easy it is to fix the problem. This blog post will ensure that not only I remember, but the entire Internet will remember the solution I use.

Here goes.

The Problem

The problem is simple: You pull down a repository that uses NPM for package management onto your Windows machine, you type npm install and you get something like this:

1
npm ERR! Failed at the <package>@<version> install script 'node-gyp rebuild'

or

1
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

This is because the project you're trying to build requires the node-gyp package to build something natively on the platform. That package required Python 2.7 and a few other pieces too.

The Solution

Simple problems sometimes get simple solutions.

Thanks to the node-gyp team, that is the case and they have documented it in the project README.

Using a PowerShell CLI instance with administrative priviledges, and use the following code:

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

And that's it.

There is a manual option as well, but I haven't needed to use it as the first option always works for me.


David Wesst

Email Email
Web Web
Twitter Twitter
GitHub GitHub
LinkedIN LinkedIn
RSS

Looking for someone else?

You can find the rest of the Western Devs Crew here.

© 2015 Western Devs. All Rights Reserved. Design by Karen Chudobiak, Graphic Designer