FIX – Windows NPM Node-gyp error for various NPM modules

By February 18, 2017 No Comments

If you’ve ever tried to install an NPM module like Xml2Js and received these pretty little errors followed by a failure to install Xml2Js (or any NPM module that requires node-gyp), there’s no need to go nuts and install all the dependencies yourself or configure system variables. Just for reference, here’s what your node-gyp errors will look like:

gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:449:14)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:404:11
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29

Luckily, Node-gyp made this much easier, see docs here:

From your command line, run:

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

then run

npm install --global node-gyp

Go ahead and install your desired package again and you should be good to go.

Special thanks to Dawid on StackOverflow for saving me hours of pain:



Author Dave

More posts by Dave