I am getting into a Node.js codebase which requires that I download a few dependencies via NPM, namely jQuery.
In attempting to run npm install jquery
, I keep getting this error:
Your environment has been set up for using Node.js 0.8.21 (x64) and NPM
C:\Users\Matt Cashatt>npm install jquery
npm http GET https://registry.npmjs.org/jquery
npm http 304 https://registry.npmjs.org/jquery
npm http GET https://registry.npmjs.org/jsdom
npm http GET https://registry.npmjs.org/xmlhttprequest
npm http GET https://registry.npmjs.org/htmlparser/1.7.6
npm http GET https://registry.npmjs.org/location/0.0.1
npm http GET https://registry.npmjs.org/navigator
npm http GET https://registry.npmjs.org/contextify
npm http 304 https://registry.npmjs.org/htmlparser/1.7.6
npm http 304 https://registry.npmjs.org/xmlhttprequest
npm http 304 https://registry.npmjs.org/location/0.0.1
npm http 304 https://registry.npmjs.org/navigator
npm http 304 https://registry.npmjs.org/jsdom
npm http 304 https://registry.npmjs.org/contextify
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/cssom
npm http GET https://registry.npmjs.org/cssstyle
npm http GET https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/bindings
> [email protected] install C:\Users\Matt Cashatt\node_modules\jquery\node_module
s\contextify
> node-gyp rebuild
C:\Users\Matt Cashatt\node_modules\jquery\node_modules\contextify>node "C:\Progr
am Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\b
in\node-gyp.js" rebuild
npm http 304 https://registry.npmjs.org/cssstyle
npm http 304 https://registry.npmjs.org/cssom
npm http 304 https://registry.npmjs.org/request
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack at failNoPython (C:\Program Files\nodejs\node_modules\npm\nod
e_modules\node-gyp\lib\configure.js:113:14)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:82:11
gyp ERR! stack at Object.oncomplete (fs.js:297:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modu
les\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Matt Cashatt\node_modules\jquery\node_modules\contextify
gyp ERR! node -v v0.8.21
gyp ERR! node-gyp -v v0.8.4
gyp ERR! not ok
npm ERR! error rolling back Error: ENOTEMPTY, rmdir 'C:\Users\Matt Cashatt\node_
modules\jquery\node_modules\jsdom\node_modules\request\tests'
npm ERR! error rolling back [email protected] { [Error: ENOTEMPTY, rmdir 'C:\Users\M
att Cashatt\node_modules\jquery\node_modules\jsdom\node_modules\request\tests']
npm ERR! error rolling back errno: 53,
npm ERR! error rolling back code: 'ENOTEMPTY',
npm ERR! error rolling back path: 'C:\\Users\\Matt Cashatt\\node_modules\\jque
ry\\node_modules\\jsdom\\node_modules\\request\\tests' }
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `cmd "/c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the contextify package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls contextify
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "jquery"
npm ERR! cwd C:\Users\Matt Cashatt
npm ERR! node -v v0.8.21
npm ERR! npm -v 1.2.11
npm ERR! code ELIFECYCLE
npm ERR! Error: ENOENT, lstat 'C:\Users\Matt Cashatt\node_modules\jquery\node_mo
dules\jsdom\node_modules\request\tests\test-pipes.js'
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <[email protected]>
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "jquery"
npm ERR! cwd C:\Users\Matt Cashatt
npm ERR! node -v v0.8.21
npm ERR! npm -v 1.2.11
npm ERR! path C:\Users\Matt Cashatt\node_modules\jquery\node_modules\jsdom\node_
modules\request\tests\test-pipes.js
npm ERR! fstream_path C:\Users\Matt Cashatt\node_modules\jquery\node_modules\jsd
om\node_modules\request\tests\test-pipes.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fst
ream\lib\writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:297:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\Matt Cashatt\npm-debug.log
npm ERR! not ok code 0
C:\Users\Matt Cashatt>
It looks like the failure is due to a missing Python installation. Well, I have installed Python, set the variable, and rebooted and still the error.
Any clue as to what I am missing?
there are some solution to solve this issue : 1 ) run your command prompt as "administrator".
if first solution doesn't solve your problem try this one :
2 ) open a command prompt as administrator paste following line of code and hit enter :
npm install --global --production windows-build-tools
i can't help but to mention this. If you're using Python3 and failing with node-gyp, then i'm sad to tell you node-gyp currently doesn't support python3.
Here is a link for you: https://github.com/nodejs/node-gyp/issues/1268 https://github.com/nodejs/node-gyp/issues/193
Set path like below and it will work
> set PYTHON=D:\\ranjith\\installed\\python-3.6.4\\python.exe
> npm config set python D:\\ranjith\\installed\\python-3.6.4\\python.exe
Then build your project (for me like)
> yarn build
Example : pg_config not executable / error node-gyp
Solution : On windows just try to add PATH Env -> C:\Program Files\PostgreSQL\12\bin
Work for me, Now i can use npm i pg-promise for example or other dependencies.
Why not downloading the python installer here ? It make the work for you when you check the path installation
For me,
The issue was that i was using node's latest version and not the LTS
version which is the stable version and recommended for most users.
Using the LTS
Version solved the issue.
You can download from here :
I met the same challenge while trying to install [email protected].
And after looking at the current official documentation, and having read the answers above, i noticed that you might not necessarily have to install node-gyp nor install windows-build tools. This is what it says, here about installing node-gyp on windows. Remember node-gyp is involved in the installation process of node-sass. And you don't really have to re-install another python version.
This is the savior, configure the python path that "npm" should look for while installing any packages that require build-tools.
C:\> npm config set python /Python36/python
I had installed python3.6.3, on windows-7, there.
The following worked for me from the command line as admin:
Installing windows-build-tools (this can take 15-20 minutes):
npm --add-python-to-path='true' --debug install --global windows-build-tools
Adding/updating the environment variable:
setx PYTHON "%USERPROFILE%\.windows-build-tools\python27\python.exe"
Installing node-gyp:
npm install --global node-gyp
Changing the name of the exe file from Python to Python2.7.
C:\Users\username\.windows-build-tools\python27\Python2.7
npm install module_name --save
Here is the correct command: set path=%path%;C:\Python34 [Replace with the correct path of your python installation]
I had the same problem and I just solved this like that.
As some other people pointed out, this is volatile configuration, it only works for the current cmd session, and (obviously) you have to set your path before you run npm install.
I hope this helps.
Here is a guide that resolved a lot of these issues for me.
http://www.steveworkman.com/node-js/2012/installing-jsdom-on-windows/
I remember in particular the python version as important. Make sure you install 2.7.3 instead of 3's.
I had the same issue and none of these answers did help. In my case PYTHON variable was set correctly. However python was installed too deep, i.e. has too long path. So, I did the following:
And that’s it!
One and/or multiple of those should help:
Add C:\Python27\
to your PATH
variable (considering you have Python installed in this directory)
How to set PATH
env variable: http://www.computerhope.com/issues/ch000549.htm
Restart your console and/or Windows after setting variable.
In the same section as above ("Environment Variables"), add new variable with name PYTHON
and value C:\Python27\python.exe
Restart your console and/or Windows after setting variable.
Open Windows command line (cmd
) in Admin mode.
Change directory to your Python installation path: cd C:\Python27
Make symlink needed for some installations: mklink python2.7.exe python.exe
Please note that you should have Python 2.x, NOT 3.x, to run node-gyp
based installations!
The text below says about Unix, but Windows version also requires Python 2.x:
You can install with npm:
$ npm install -g node-gyp
You will also need to install:
On Unix:
python (v2.7 recommended, v3.x.x is not supported)
make
A proper C/C++ compiler toolchain, like GCC
This article may also help: https://github.com/nodejs/node-gyp#installation
If you haven't got python installed along with all the node-gyp dependencies, simply open Powershell or Git Bash with administrator privileges and execute:
npm install --global --production windows-build-tools
and then to install the package:
npm install --global node-gyp
once installed, you will have all the node-gyp dependencies downloaded, but you still need the environment variable. Validate Python is indeed found in the correct folder:
C:\Users\ben\.windows-build-tools\python27\python.exe
Note - it uses python 2.7 not 3.x as it is not supported
If it doesn't moan, go ahead and create your (user) environment variable:
setx PYTHON "%USERPROFILE%\.windows-build-tools\python27\python.exe"
restart cmd, and verify the variable exists via set PYTHON
which should return the variable
Lastly re-apply npm install <module>
gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT HON env variable.
Not necessary to reinstall, this exception throw by node-gyp script, then try to rebuild. It's enough setup environment variable like in my case I did:
SET PYTHON=C:\work\_env\Python27\python.exe
TL;DR Make a copy or alias of your python.exe with name python2.7.exe
My python 2.7 was installed as
D:\app\Python27\python.exe
I always got this error no matter how I set (and verified) PYTHON env variable:
gyp ERR! stack Error: Can't find Python executable "python2.7", 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:103:14)
The reason for this was that in node-gyp's configure.js the python executable was resolved like:
var python = gyp.opts.python || process.env.PYTHON || 'python'
And it turned out that gyp.opts.python had value 'python2.7' thus overriding process.env.PYTHON.
I resolved this by creating an alias for python.exe executable with name node-gyp was looking for:
D:\app\Python27>mklink python2.7.exe python.exe
You need admin rights for this operation.
This is most easiest way to let NPM do everything for you
npm --add-python-to-path='true' --debug install --global windows-build-tools
This helped: https://www.npmjs.com/package/node-gyp
I followed these steps:
npm install -g node-gyp
then:
npm install --global --production windows-build-tools
For me after installing windows-build-tools with the below comment
npm --add-python-to-path='true' --debug install --global windows-build-tools
running the code below
npm config set python "%USERPROFILE%\.windows-build-tools\python27\python.exe"
has worked.
For me, these steps fixed the issue:
1- Running this cmd as admin:
npm install --global --production windows-build-tools
2- Then running npm rebuild
after the 1st step is completed (especially completing the python 2.7 installation, which was the main cause of the issue)
If you're trying to use this on Cygwin, then you need to follow the instructions in this answer. (It's a problem how Cygwin treats Windows symlinks.)
Source: Stackoverflow.com