node-gyp: node-gyp rebuild error

/usr/local/lib/node_modules# node-gyp rebuild


gyp info it worked if it ends with ok
gyp info using node-gyp@0.5.7
gyp info using node@0.8.1
gyp info spawn python
gyp info spawn args [ '/root/.node-gyp/0.8.1/tools/gyp_addon',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-I/usr/local/lib/node_modules/build/config.gypi',
gyp info spawn args   '-f',
gyp info spawn args   'make' ]
Traceback (most recent call last):
  File "/root/.node-gyp/0.8.1/tools/gyp_addon", line 38, in <module>
    rc = gyp.main(gyp_args)
  File "/root/.node-gyp/0.8.1/tools/gyp/pylib/gyp/__init__.py", line 471, in main
    options.circular_check)
  File "/root/.node-gyp/0.8.1/tools/gyp/pylib/gyp/__init__.py", line 111, in Load
    depth, generator_input_info, check, circular_check)
  File "/root/.node-gyp/0.8.1/tools/gyp/pylib/gyp/input.py", line 2289, in Load
    depth, check)
  File "/root/.node-gyp/0.8.1/tools/gyp/pylib/gyp/input.py", line 361, in LoadTargetBuildFile
    includes, True, check)
  File "/root/.node-gyp/0.8.1/tools/gyp/pylib/gyp/input.py", line 208, in LoadOneBuildFile
    raise Exception("%s not found (cwd: %s)" % (build_file_path, os.getcwd()))
Exception: binding.gyp not found (cwd: /usr/local/lib/node_modules) while trying to load binding.gyp
gyp ERR! rebuild error Error: `gyp_addon` failed with exit code: 1
gyp ERR! rebuild error     at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:290:16)
gyp ERR! rebuild error     at ChildProcess.EventEmitter.emit (events.js:91:17)
gyp ERR! rebuild error     at Process._handle.onexit (child_process.js:674:10)
gyp ERR! not ok 

About this issue

  • Original URL
  • State: closed
  • Created 12 years ago
  • Comments: 35 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Your solution does not work, this is still broken.

Everyone, node-gyp configure must be run from the root directory of a node module. @jamcoupe Invoking it at / is likely not what you want to do.

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

@ctzurcanu what are you trying to use node-gyp for? It’s a tool for building native node modules, and every native node module should have a binding.gyp file in the root.

For example, you could clone node-report (a small native module in the nodejs foundation), and run node-gyp configure in that.

npm install -g node-gyp # This should put node-gyp in the path if it's not already
git clone https://github.com/nodejs/node-report.git
cd node-report
node-gyp configure

Update, looks like @krylatij was on point. You have to run configure in a folder where binding.gyp is, or you will get this error.

Problem solved once I found the right folder.

Go to the folder with binding.gyp of your module and run “node-gyp configure” from it.

binding.gyp does not exist…

ERSmith@S7-ERSMITH-L MINGW64 ~/AppData/Roaming/npm/node_modules/node-gyp/gyp
$ node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@3.4.0
gyp info using node@6.9.1 | win32 | x64
gyp info spawn C:\Python27\python.EXE
gyp info spawn args [ 'C:\\Users\\ERSmith\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main                                           .py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=auto',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\ERSmith\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\build\\c                                           onfig.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\ERSmith\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\ERSmith\\.node-gyp\\6.9.1\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\ERSmith\\.node-gyp\\6.9.1',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\ERSmith\\AppData\\Roaming\\npm\\node_modules\\node-gyp                                           ',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\ERSmith\\AppData\\Roaming\\npm\\node_modules\\node-                                           gyp\\gyp',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\Users\\ERSmith\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp: binding.gyp not found (cwd: C:\Users\ERSmith\AppData\Roaming\npm\node_modules\node-gyp\gyp) 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 (C:\Users\ERSmith\AppData\Roaming\npm\node_modules\node-gyp                                           \lib\configure.js:305: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 Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ERSmith\\AppData\\Roaming\\npm\\node                                           _modules\\node-gyp\\bin\\node-gyp.js" "configure"
gyp ERR! cwd C:\Users\ERSmith\AppData\Roaming\npm\node_modules\node-gyp\gyp
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok

+1 for mac

same here ubuntu. damn hate this issue

Having the same problem with @seatownrocks, but on Ubuntu 16.04 LTS.

$ sudo node-gyp configure build
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.0
gyp info using node@7.7.3 | linux | x64
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/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   '/usr/lib/node_modules/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.node-gyp/7.7.3/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/root/.node-gyp/7.7.3',
gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/usr/lib/node_modules',
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: /usr/lib/node_modules) 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/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:194:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-22-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/bin/node-gyp" "configure" "build"
gyp ERR! cwd /usr/lib/node_modules
gyp ERR! node -v v7.7.3
gyp ERR! node-gyp -v v3.6.0
gyp ERR! not ok 

sudo npm i

@ctzurcanu I don’t think wekan is a native module. node-gyp is for building native modules (i.e. C++ code not just JavaScript).

But basically if you just want to use modules, npm install should just work (for native and non-native modules), you shouldn’t need to use node-gyp directly.

After hours of struggling with this issue. All I did was npm config set GYP_MSVS_VERSION 2015. I also pointed Python to npm as well as Visual Studio version. Your .npmrc file found in the home directory should look like this:

msvs_version=2015 python=C:Python27python.exe GYP_MSVS_VERSION=2015

Ofcourse having Visual C++ installed together with Visual Studio (I used community edition, it had both)

@gibfahn thank you. I wanted to build https://github.com/wekan/wekan and i see no binding.gyp in the source while in node-report is clearly present in the root… I should understand that the source there is incomplete.

one of about 7 issues i’ve been having installing node-gyp

So, I tried to use that : npm install iconv -g

And got this error.