34

I'm trying to run node-gyp configure, but am getting the following errors:

gyp: binding.gyp not found (cwd: /usr/local/bin)
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:337:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.0.0
gyp ERR! command "node" "/usr/local/bin/node-gyp" "configure"
gyp ERR! cwd /usr/local/bin
gyp ERR! node -v v0.10.20
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 

I think that I'm in the wrong directory, but I'm not sure. Which directory should I be in to run this?

Joshua Kleveter
  • 1,769
  • 17
  • 23
gabriella
  • 371
  • 1
  • 3
  • 8
  • 6
    `node-gyp configure build` is used to build your package which has c/c++ files. You can `cd` to package folder where has a file `binding.gyp` then type `node-gyp configure build` or `node-gyp rebuild` – damphat Jan 03 '14 at 21:31
  • Make sure you have the developer tools installed through xcode. – Jeff Sloyer May 07 '15 at 13:12
  • i have the same problem too, in my case i forgot to change the file name from `binding.gyp.txt` to `binding.gyp`, maybe that can help you – anztrax Apr 13 '16 at 17:07

6 Answers6

7

You are trying to run node-gyp rebuild in current working directory (CWD) /usr/local/bin so the node-gyp can not find binding at /usr/local/bin/binding.gyp.

Navigate your terminal to a directory which contains NodeJS module and only then run node-gyp rebuild.

cd ~/Projects/your-nodejs-native-module/
node-gyp rebuild

BTW I am not sure from which node version exactly but in modern versions, you can just run npm install in this directory and npm will run node-gyp rebuild for you.

cd ~/Projects/your-nodejs-native-module/
npm install
h0x91B
  • 1,211
  • 15
  • 19
  • 1
    Running `node-gyp rebuild` kept failing for me, but a full `npm install` made the job – Tdy May 01 '17 at 13:31
1

if in doubt first re-install npm install -g node-gyp.

It's best practice to run node-gyp rebuild. Run it from your project's root. Also your binding.gyp should be in the root, pointing to dependencies (somewhere else).

In general there shouldn't be any need to run node-gyp configure manually.

eljefedelrodeodeljefe
  • 6,304
  • 7
  • 29
  • 61
0

By the look of the things (not 100% sure) /usr/local/bin does not exist in your computer. But it is hard to say from the stack-trace.

dagonza
  • 259
  • 1
  • 11
0

I have had this problem with newer versions of node. My best work around has been using something like node version manager (nvm) to revert back to an older version of node and then running npm install again.

Zach Janicki
  • 64
  • 1
  • 3
0

Install node-gyp globally first:

sudo npm -g install node-gyp

Please see this answer

Community
  • 1
  • 1
ShahNewazKhan
  • 1,057
  • 1
  • 12
  • 26
0

I got this issue while working on Angular 10 project on macOS Big Sur 11.5.1

This answer on stack overflow solved it for me - https://stackoverflow.com/a/55590251/10622142

  1. Delete package-lock.json
  2. Run command => npm install
Amlan Alok
  • 99
  • 2
  • 8
  • This answer is exactly the same as [another you posted](https://stackoverflow.com/a/68736767/14267427). If you think this question is a duplicate, suggest a duplicate. – Tyler2P Aug 11 '21 at 11:17
  • @Tyler2P What exactly do you mean by "suggest a duplicate"? Do you mean give the link to the other thread and say this is a duplicate of that here? – Amlan Alok Aug 13 '21 at 05:40