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

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:

[code lang=”js”]
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
[/code]
Luckily, Node-gyp made this much easier, see docs here: https://github.com/nodejs/node-gyp

From your command line, run:
[code lang=”js”]
npm install –global –production windows-build-tools
[/code]
then run
[code lang=”js”]
npm install –global node-gyp
[/code]
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: http://stackoverflow.com/a/21366601/2121455

 

About The Author