nodejs/node-gyp

binding.gyp not found (cwd: c:\Users\xxxx\xxxx\) while trying to load binding.gyp

Closed this issue ยท 49 comments

Hi

Iam having trouble to configure "node-gyp",
I followed this article "https://github.com/nodejs/node-gyp" for installation of "node-gyp", and it was working before i messed up my configuration on my computer, node-gyp just stop working. By searching on google i found different explanations, but nothing fixed my issue.

Below is screenshot of when i Run the command "node-gyp configure"
I hope that the path to root directory is correct?

node

By searching on google i found out that if i put an empety binding.gyp file in folder where iam running the command to configure node-gyp , then something start happening, but then i get another error to . So something is maybe missing here or i have done something i cant figure out...

I have installed VS2012 Express and VS2015 PRO, i also have run the npm command to set python and npm to --msvs_version=auto

Any clue on how to configure node-gyp on windows 8.1?

What exactly are you trying to do? node-gyp is for building add-ons. From your screenshot, it looks like you're trying to build node-gyp itself.

oki, iam trying to install bcrypt, when i first tried to install bcrypt i got an error saying that i need to run node-gyp rebuild, and thats where all started... I need to install Bcrypt...

And i have done all the installation steps described:

I need to install bcrypt...

bnoordhuis , Where shoud i run this command from? in witch directory?

In installation describtions they say that you need to run the command from the root directory of you node.....what does it mean?

node-gyp is installed along with npm, there should be no need to install it separately. If you get an error when you npm install bcrypt, you should take that up with the bcrypt project first.

I no that, problom is when i try to install bcrypt i get an error saying that i have to run "node-gyp configure" before installing the bcrypt. And when i run node-gyp configure, i get another error saying that node-gyp cannot find the binding.gyp file......!! And i cant find any binding.gyp file in the root of directory....

You should not need to run node-gyp configure manually. This happens implicitly when npm install bcrypt is run.

Closing since not a node-gyp issue.

the solution in my case was to run this command:

set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%

I am getting the same issue. I tried a lot but couldnt fix this issue. Setting Path with MSBuild is also not working for e. I am getting this issue when I am trying to install ursa module. Also, i am using VS2012 Express.Please help
npm install

Try running the following commands and then run npm install, this will take the node's default node-gyp module. (No need to have multiple as node package already provides that)

Updating the node & NPM

sudo npm cache clean -f
sudo npm install -g n
sudo n 4.4.5
sudo npm install npm -g

Removing additional Node-gyp module

sudo npm uninstall node-gyp -g
sudo npm uninstall node-gyp

I am running into the same problem, the sudo commands are not applicable to a windows environment (and the npm package 'n' is not either). I get the same binding.gyp, and that's after successfully reinstalling node-gyp using the msvs_version. Elsewhere I've seen suggestions to reinstall Python. Anyone have other ideas?

+1

wzup commented

+1

Just use VS developer command prompt if you have VS

+1

td4b commented

+1

I fixed it somehow after two weeks or so. It was a hell of trial and error.
The process was so complex, that at the end I wasn't sure what fixed it.
Gyp is an illness. Good luck!

Personal possible fix reasons on Win 7 from my notes (without any warranty):

  • C++ Build Tools + Win 8 SDK + Win 10 SDK
  • Env Vars: GYP_MSVS_VERSION = 2015
  • VS140COMNTOOLS = C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools
    Path = %ProgramFiles%\MSBuild\14.0\Bin;[...]
  • latest Python 2.x
  • reboot
  • I also did something under /node_modules/ for specific appliances like Electron, SQlite etc.

PS:
Possibly the worst error traps (with tons of side effects), I've ever seen in my developer career.
We all should know who did this crappy shit to us.
And why the hell this issue is still closed and not fixed in general.

Trial and error belongs to machine learning, not to essential developer tools used by humans.

the same issue and no solution

I feel pretty silly, but I realized that I didn't have Visual C++ 2015 Build Tools and Visual Studio with Common Build tools (or relevant C++ addons). I installed both of those and didn't have this problem anymore.

mounika$ node-gyp configure --msvs_version=2015
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.1
gyp info using node@7.4.0 | darwin | x64
gyp info spawn /usr/bin/python
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/mounika/FULLClient-Electron-aw-lily/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/mounika/.node-gyp/7.4.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/mounika/.node-gyp/7.4.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/mounika/FULLClient-Electron-aw-lily',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp: binding.gyp not found (cwd: /Users/mounika/FULLClient-Electron-aw-lily) while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 16.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/bin/node-gyp" "configure" "--msvs_version=2015"
gyp ERR! cwd /Users/mounika/FULLClient-Electron-aw-lily
gyp ERR! node -v v7.4.0
gyp ERR! node-gyp -v v3.6.1
gyp ERR! not ok 

Can anyone help me to solve this error?

@SaiMounikaRao is there a binding.gyp file in your working directory (/Users/mounika/FULLClient-Electron-aw-lily)?

Also it looks like you're using a Mac, but --msvs_version=2015 is a Windows specific option.

No binding.gyp is not present in my directory.

@SaiMounikaRao so what exactly are you trying to do? You should just be able to do npm install in /Users/mounika/FULLClient-Electron-aw-lily, I'm not sure why you're running node-gyp directly.

Ya I got it now it's working fine.
Actually I have already done with "npm install" in my directory after that when I am trying to run my code it's showing that error. So I have tried with different things and now my problem got solved.

how did you resolved your problem??

Suggested solutions that came up in this thread:

  1. Make sure you have a compiler set up - https://github.com/nodejs/node-gyp/#installation
  2. Make sure you have the latest npm - https://docs.npmjs.com/getting-started/installing-node
  3. sometimes node-gyp does not need to be run directly, running npm i will trigger it #702 (comment)

@mailparikshit what exactly is the problem you are seeing? You could open a new issue with the error out you got?

I create binding.gyp file manually under the path c:\users\leon\appdata\roaming\npm\node_modules\node-gyp with following content:
{
"targets": [
{
"target_name": "binding",
"sources": [ "build/Release/binding.node" ]
}
]
}.
After that, I run node-gyp rebuild command and the issue is solved.

I think we just shouldn't try to node-gyp rebuild, because, in most of cases, it will not solve any other issues.

btoo commented

im using the Windows Subsystem for Linux and i was able to fix my problem by doing sudo apt-get install g++

@shraddha22 I got the same issue as you. have you solved it ? (๏ผ›โ€ฒโŒ’`)

I was able to solve with npm install --global --production windows-build-tools available at https://www.npmjs.com/package/windows-build-tools.

Sometimes I needed to uninstall and reinstall some software for a fresh start, but everything works fine after the build tools instalation.

I've been running for the same issue for the past few days, here what you need to do :

I guess most people (it was my case) forget to simply add binding.gyp

Hope it helps ...

My solution on Windows 10.
Only these solution helps.
You need file visualcppbuildtools_full.exe !!
Go here https://visualstudio.microsoft.com/ru/visual-cpp-build-tools/
My link: https://download.microsoft.com/download/5/f/7/5f7acaeb-8363-451f-9425-68a90f98b238/visualcppbuildtools_full.exe
You require file: visualcppbuildtools_full.exe.
Install all versions for windows 8.1 and 10 (~6-8Gb).
Its create folder C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140...
And be happy :-)

I create binding.gyp file manually under the path c:\users\leon\appdata\roaming\npm\node_modules\node-gyp with following content:
{
"targets": [
{
"target_name": "binding",
"sources": [ "build/Release/binding.node" ]
}
]
}.
After that, I run node-gyp rebuild command and the issue is solved.

Best answer .

My solution on Windows 10.
Only these solution helps.
You need file visualcppbuildtools_full.exe !!
Go here https://visualstudio.microsoft.com/ru/visual-cpp-build-tools/
My link: https://download.microsoft.com/download/5/f/7/5f7acaeb-8363-451f-9425-68a90f98b238/visualcppbuildtools_full.exe
You require file: visualcppbuildtools_full.exe.
Install all versions for windows 8.1 and 10 (~6-8Gb).
Its create folder C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140...
And be happy :-)

it is useful

I create binding.gyp file manually under the path c:\users\leon\appdata\roaming\npm\node_modules\node-gyp with following content:
{
"targets": [
{
"target_name": "binding",
"sources": [ "build/Release/binding.node" ]
}
]
}.
After that, I run node-gyp rebuild command and the issue is solved.

This worked for me!
Here is a more detailed answer...

If you run node-gyp rebuild, or in my dumb case sudo node-gyp rebuild -g --unsafe-perm=true, you will probably be looking at a bunch of these logs... gyp ERR! ....

Right in-between the gyp info and the gyp ERR! look for something like this...
gyp: binding.gyp not found (cwd: /Users/yourUsername/Documents/YourProject/YourSubFolder) while trying to load binding.gyp

This is the folder where you need to add a binding.gyp file that contains...

{
	"targets": [
		{
			"target_name": "binding",
			"sources": [ "build/Release/binding.node" ]
		}
	]
}

Then try running node-gyp rebuild again! Good luck all!

Try running the following commands and then run npm install, this will take the node's default node-gyp module. (No need to have multiple as node package already provides that)

Updating the node & NPM

sudo npm cache clean -f
sudo npm install -g n
sudo n 4.4.5
sudo npm install npm -g

Removing additional Node-gyp module

sudo npm uninstall node-gyp -g
sudo npm uninstall node-gyp

This solve my issue, thanks man

If you, like me, found this page and do not understand what all these people are talking about but having the same problem (error message when trying to install yarn/npm install) maybe we are in the same boat.

I understand that it is a little off-topic, but I hope it helps someone:

So I got this error trying to install something with dependency on node-sass.
The node-sass dependency has older version and apparently does not support the latest node version I have on my computer.
So to solve this I could either upgrade node-sass or downgrade node.

Cheers.

@pauljfx to which version of node did you downgrade - is 11 fine or do you need to go back further?

I used nvm for windows, installed node version 11.14.0 and it worked for me.

Maybe this helps you if you are on MacOS catalina (v.10.15.XX).

https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md

node-sass

This brought me here. I updated my nodejs to 12 and apparently i didnt check node-sass for compatibility setting it's version to 4.13.1 fixed the whole thing. (remove node_models and package-lock.json afterwards and npm i )

I create binding.gyp file manually under the path c:\users\leon\appdata\roaming\npm\node_modules\node-gyp with following content:
{
"targets": [
{
"target_name": "binding",
"sources": [ "build/Release/binding.node" ]
}
]
}.
After that, I run node-gyp rebuild command and the issue is solved.

Why did you put a period at the end? It works without the period. Perhaps obvious to some, but not all.

This is the folder where you need to add a binding.gyp file that contains...

{
	"targets": [
		{
			"target_name": "binding",
			"sources": [ "build/Release/binding.node" ]
		}
	]
}

Then try running node-gyp rebuild again! Good luck all!

This worked for me.

I had the same issue on Ubuntu 18.04. I needed to switch the python version to 2.7 to solve it:

update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1

Yeah. If there are the lines...

gyp ERR! node -v v0.12.4
gyp ERR! node-gyp -v v2.0.2

... like it says above then you have to use legacy Python because you are using legacy Node and legacy Node-gyp.

Perhaps provide 1. the command that you typed and 2. the full output so that we are not flying blind.

I create binding.gyp file manually under the path c:\users\leon\appdata\roaming\npm\node_modules\node-gyp with following content:
{
"targets": [
{
"target_name": "binding",
"sources": [ "build/Release/binding.node" ]
}
]
}.
After that, I run node-gyp rebuild command and the issue is solved.

Please can you tell me how you created the file? Im new to this. I cant figure it out

I've been running for the same issue for the past few days, here what you need to do :

I guess most people (it was my case) forget to simply add binding.gyp

Hope it helps ...

Isn't this file supposed to be inside the node module that you are installing?

I am not sure
maybe this work
node-gyp configure