Node-gyp: Not able to install using npm because of (node-gyp rebuild) in Ubuntu 12.04 LTS running on free tier Amazon EC2 Instance

Created on 10 Sep 2012  路  19Comments  路  Source: nodejs/node-gyp

npm install exec-sync
npm http GET https://registry.npmjs.org/exec-sync
npm http 200 https://registry.npmjs.org/exec-sync
npm http GET https://registry.npmjs.org/exec-sync/-/exec-sync-0.1.4.tgz
npm http 200 https://registry.npmjs.org/exec-sync/-/exec-sync-0.1.4.tgz
npm http GET https://registry.npmjs.org/ffi/1.0.1
npm http 200 https://registry.npmjs.org/ffi/1.0.1
npm http GET https://registry.npmjs.org/ffi/-/ffi-1.0.1.tgz
npm http 200 https://registry.npmjs.org/ffi/-/ffi-1.0.1.tgz
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/ref
npm http GET https://registry.npmjs.org/ref-struct
npm http 200 https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/bindings/-/bindings-1.0.0.tgz
npm http 200 https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/debug/-/debug-0.7.0.tgz
npm http 200 https://registry.npmjs.org/ref-struct
npm http GET https://registry.npmjs.org/ref-struct/-/ref-struct-0.0.3.tgz
npm http 200 https://registry.npmjs.org/ref
npm http GET https://registry.npmjs.org/ref/-/ref-0.1.2.tgz
npm http 200 https://registry.npmjs.org/bindings/-/bindings-1.0.0.tgz
npm http 200 https://registry.npmjs.org/ref-struct/-/ref-struct-0.0.3.tgz
npm http 200 https://registry.npmjs.org/debug/-/debug-0.7.0.tgz
npm http 200 https://registry.npmjs.org/ref/-/ref-0.1.2.tgz

> [email protected] install /root/node/node_modules/exec-sync/node_modules/ffi/node_modules/ref
> node-gyp rebuild

gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES, stat '/root/.node-gyp/0.8.6'
gyp ERR! System Linux 3.2.0-25-virtual
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/node/node_modules/exec-sync/node_modules/ffi/node_modules/ref
gyp ERR! node -v v0.8.6
gyp ERR! node-gyp -v v0.6.3
gyp ERR! not ok 
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `sh "-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 ref 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 ref
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.2.0-25-virtual
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "exec-sync"
npm ERR! cwd /root/node
npm ERR! node -v v0.8.6
npm ERR! npm -v 1.1.48
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /root/node/npm-debug.log
npm ERR! not ok code 0

Most helpful comment

npm config set unsafe-perm true
ok...

All 19 comments

Try updating to the latest npm/node-gyp. There should be a workaround in place for when that happens now.

Using the latest version of node-gyp that's available on npm, I get same EACCES error on node-gyp rebuild for the "weak" package on OS X.

Guys there's really no point in using sudo when you npm install modules.

That said, it _should_ still just work. @joeblynch Can you give me the full output you see on your screen?

With the way Node installs by default on OS X, you do have to sudo if you are doing a npm install -g, because global modules are stored in /usr/local/lib/node_modules.

I was able to work around this for now, by doing a a non-global install and then adding the node_modules/.bin to my PATH. Not an ideal solution, but it works for now.

Here's my output for sudo npm install -g fleet, which has a dep on weak:

npm http GET https://registry.npmjs.org/fleet
npm http 304 https://registry.npmjs.org/fleet
npm http GET https://registry.npmjs.org/propagit
npm http GET https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/archy
npm http 304 https://registry.npmjs.org/optimist
npm http 304 https://registry.npmjs.org/propagit
npm http 304 https://registry.npmjs.org/archy
npm http 304 https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/upnode
npm http GET https://registry.npmjs.org/pushover
npm http GET https://registry.npmjs.org/wordwrap
npm http 304 https://registry.npmjs.org/upnode
npm http 304 https://registry.npmjs.org/pushover
npm http 304 https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/dnode
npm http 304 https://registry.npmjs.org/dnode
npm http GET https://registry.npmjs.org/dnode-protocol
npm http GET https://registry.npmjs.org/jsonify
npm http GET https://registry.npmjs.org/weak
npm http 304 https://registry.npmjs.org/dnode-protocol
npm http 304 https://registry.npmjs.org/jsonify
npm http 304 https://registry.npmjs.org/weak
npm http GET https://registry.npmjs.org/traverse
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/traverse
npm http 304 https://registry.npmjs.org/bindings

> [email protected] install /usr/local/lib/node_modules/fleet/node_modules/propagit/node_modules/upnode/node_modules/dnode/node_modules/weak
> node-gyp rebuild

gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES, stat '/Users/jlynch/.node-gyp/0.8.9'
gyp ERR! System Darwin 12.1.0
gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/fleet/node_modules/propagit/node_modules/upnode/node_modules/dnode/node_modules/weak
gyp ERR! node -v v0.8.9
gyp ERR! node-gyp -v v0.6.10
gyp ERR! not ok 
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `sh "-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 weak 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 weak
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 12.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "fleet"
npm ERR! cwd /Users/jlynch/local/node_modules/.bin
npm ERR! node -v v0.8.9
npm ERR! npm -v 1.1.61
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/jlynch/local/node_modules/.bin/npm-debug.log
npm ERR! not ok code 0

With the way Node installs by default on OS X, you do have to sudo if you are doing a npm install -g, because global modules are stored in /usr/local/lib/node_modules.

I personally always chown the /usr/local directory to avoid that. See the "What? no sudo?" section of http://howtonode.org/introduction-to-npm for more details on how to do that.

@joeblynch Hmm, seems like my fallback isn't kicking in for you for some reason. Can you give me the full output with --verbose attached to the command? Thanks!

Thanks for the info on the "no sudo" method, I'll be going with that going forward.

Here's the verbose output for sudo npm install -g --verbose weak

npm info it worked if it ends with ok
npm verb cli [ 'node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'install',
npm verb cli   '-g',
npm verb cli   '--verbose',
npm verb cli   'weak' ]
npm info using [email protected]
npm info using [email protected]
npm verb read json /usr/local/lib/package.json
npm verb read json /usr/local/lib/package.json
npm verb cache add [ 'weak', null ]
npm verb parsed url { pathname: 'weak', path: 'weak', href: 'weak' }
npm verb lock weak /Users/jlynch/.npm/1ded3053-weak.lock
npm verb addNamed [ 'weak', '' ]
npm verb addNamed [ null, '' ]
npm verb lock weak@ /Users/jlynch/.npm/810772c1-weak.lock
npm verb url raw weak
npm verb url resolving [ 'https://registry.npmjs.org/', './weak' ]
npm verb url resolved https://registry.npmjs.org/weak
npm info trying registry request attempt 1 at 16:22:16
npm verb etag "CPENWIUGFGY76UZ0IXSW2W120"
npm http GET https://registry.npmjs.org/weak
npm http 304 https://registry.npmjs.org/weak
npm verb etag weak from cache
npm verb addNamed [ 'weak', '0.2.1' ]
npm verb addNamed [ '0.2.1', '0.2.1' ]
npm verb lock [email protected] /Users/jlynch/.npm/eba97922-weak-0-2-1.lock
npm verb read json /Users/jlynch/.npm/weak/0.2.1/package/package.json
npm info install [email protected] into /usr/local/lib
npm info installOne [email protected]
npm verb from cache /Users/jlynch/.npm/weak/0.2.1/package/package.json
npm info /usr/local/lib/node_modules/weak unbuild
npm verb read json /usr/local/lib/node_modules/weak/package.json
npm verb tar unpack /Users/jlynch/.npm/weak/0.2.1/package.tgz
npm verb lock /usr/local/lib/node_modules/weak /Users/jlynch/.npm/419ce27c-usr-local-lib-node-modules-weak.lock
npm verb read json /usr/local/lib/node_modules/weak/package.json
npm info preinstall [email protected]
npm verb from cache /usr/local/lib/node_modules/weak/package.json
npm verb readDependencies using package.json deps
npm verb from cache /usr/local/lib/node_modules/weak/package.json
npm verb readDependencies using package.json deps
npm verb cache add [ 'bindings@*', null ]
npm verb parsed url { pathname: 'bindings@*',
npm verb parsed url   path: 'bindings@*',
npm verb parsed url   href: 'bindings@*' }
npm verb parsed url { pathname: '*', path: '*', href: '*' }
npm verb addNamed [ 'bindings', '*' ]
npm verb addNamed [ null, '' ]
npm verb lock bindings@* /Users/jlynch/.npm/a3858fc2-bindings.lock
npm verb url raw bindings
npm verb url resolving [ 'https://registry.npmjs.org/', './bindings' ]
npm verb url resolved https://registry.npmjs.org/bindings
npm info trying registry request attempt 1 at 16:22:16
npm verb etag "6EP3WH7QRRUQYN4C2DI090LM0"
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/bindings
npm verb etag bindings from cache
npm verb addNamed [ 'bindings', '1.0.0' ]
npm verb addNamed [ '1.0.0', '1.0.0' ]
npm verb lock [email protected] /Users/jlynch/.npm/f01e5454-bindings-1-0-0.lock
npm verb read json /Users/jlynch/.npm/bindings/1.0.0/package/package.json
npm info install [email protected] into /usr/local/lib/node_modules/weak
npm info installOne [email protected]
npm verb from cache /Users/jlynch/.npm/bindings/1.0.0/package/package.json
npm info /usr/local/lib/node_modules/weak/node_modules/bindings unbuild
npm verb read json /usr/local/lib/node_modules/weak/node_modules/bindings/package.json
npm verb tar unpack /Users/jlynch/.npm/bindings/1.0.0/package.tgz
npm verb lock /usr/local/lib/node_modules/weak/node_modules/bindings /Users/jlynch/.npm/deeb6fce-dules-weak-node-modules-bindings.lock
npm verb read json /usr/local/lib/node_modules/weak/node_modules/bindings/package.json
npm info preinstall [email protected]
npm verb from cache /usr/local/lib/node_modules/weak/node_modules/bindings/package.json
npm verb readDependencies using package.json deps
npm verb from cache /usr/local/lib/node_modules/weak/node_modules/bindings/package.json
npm verb readDependencies using package.json deps
npm verb about to build /usr/local/lib/node_modules/weak/node_modules/bindings
npm info build /usr/local/lib/node_modules/weak/node_modules/bindings
npm verb from cache /usr/local/lib/node_modules/weak/node_modules/bindings/package.json
npm verb linkStuff [ true,
npm verb linkStuff   '/usr/local/lib/node_modules',
npm verb linkStuff   false,
npm verb linkStuff   '/usr/local/lib/node_modules/weak/node_modules' ]
npm info linkStuff [email protected]
npm verb linkBins [email protected]
npm verb linkMans [email protected]
npm verb rebuildBundles [email protected]
npm info install [email protected]
npm info postinstall [email protected]
npm verb about to build /usr/local/lib/node_modules/weak
npm info build /usr/local/lib/node_modules/weak
npm verb from cache /usr/local/lib/node_modules/weak/package.json
npm verb linkStuff [ true,
npm verb linkStuff   '/usr/local/lib/node_modules',
npm verb linkStuff   true,
npm verb linkStuff   '/usr/local/lib/node_modules' ]
npm info linkStuff [email protected]
npm verb linkBins [email protected]
npm verb linkMans [email protected]
npm verb rebuildBundles [email protected]
npm verb rebuildBundles [ 'bindings' ]
npm info install [email protected]
npm verb unsafe-perm in lifecycle false

> [email protected] install /usr/local/lib/node_modules/weak
> node-gyp rebuild

npm verb set uid from=0 to=nobody
npm verb set uid from=0 to=-2
gyp info it worked if it ends with ok
gyp verb cli [ 'node', '/usr/local/bin/node-gyp', 'rebuild' ]
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded for `%s` python /usr/bin/python
gyp verb check python version `python -c "import platform; print platform.python_version();"` returned: "2.7.2\n"
gyp verb get node dir no --target version specified, falling back to host node version: v0.8.9
gyp verb command install [ 'v0.8.9' ]
gyp verb install input version string "v0.8.9"
gyp verb installing legacy version? false
gyp verb install installing version: 0.8.9
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp WARN install got an error, rolling back install
gyp verb command remove [ '0.8.9' ]
gyp verb remove using node-gyp dir: /Users/jlynch/.node-gyp
gyp verb remove removing target version: 0.8.9
gyp verb remove removing development files for version: 0.8.9
gyp ERR! configure error 
gyp ERR! stack Error: EACCES, stat '/Users/jlynch/.node-gyp/0.8.9'
gyp ERR! System Darwin 12.1.0
gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/weak
gyp ERR! node -v v0.8.9
gyp ERR! node-gyp -v v0.6.10
gyp ERR! not ok 
npm info [email protected] Failed to exec install script
npm info /usr/local/lib/node_modules/weak unbuild
npm verb from cache /usr/local/lib/node_modules/weak/package.json
npm info preuninstall [email protected]
npm info uninstall [email protected]
npm verb true,/usr/local/lib/node_modules,/usr/local/lib/node_modules unbuild [email protected]
npm info postuninstall [email protected]
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `sh "-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 weak 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 weak
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 12.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "--verbose" "weak"
npm ERR! cwd /Users/jlynch/local/node_modules/.bin
npm ERR! node -v v0.8.9
npm ERR! npm -v 1.1.61
npm ERR! code ELIFECYCLE
npm verb exit [ 1, true ]
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/jlynch/local/node_modules/.bin/npm-debug.log
npm ERR! not ok code 0

@joeblynch I bet the permissions are messed up on your /Users/jlynch/.node-gyp directory. If you removed that and tried again things should work I think.

@joeblynch And if things still don't work, can you try updating to v0.6.11? I may have caught where it was failing earlier.

It looks like doing a sudo npm install messed up the permissions to ~/.node-gyp. I tried v0.6.11 on a different OS X machine, which I hadn't chown'd /usr/local, and everything worked great. Thanks for looking into this so quickly!

I am getting this error while Kitsune invironment setup...
[email protected] install c:\mpp\kitsune\node_modulesvault\node_modules\pinball\no
de_modules\bignum

node-gyp configure build

\

[email protected] install c:\mpp\kitsune\node_modules\connect-mayfly\node_module
s\mayfly\node_modules\microtime
node-gyp rebuild

[email protected] postinstall c:\mpp\kitsune\node_modulestopos
node ./postinstall.js

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the microtime 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 microtime
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\nodej
s\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! cwd c:\mpp\kitsune
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! syscall spawn
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! not ok code 0

If anyone have any idea that why i am getting this error, pls help me.

I have the same problem:

npm install weak
-
> [email protected] install /Volumes/320gb/macbookpro/Desktop/prerender/node_modules/weak
> node-gyp rebuild

gyp ERR! UNCAUGHT EXCEPTION 
gyp ERR! stack Error: spawn EACCES
gyp ERR! stack     at exports._errnoException (util.js:746:11)
gyp ERR! stack     at ChildProcess.spawn (child_process.js:1155:11)
gyp ERR! stack     at exports.spawn (child_process.js:988:9)
gyp ERR! stack     at exports.execFile (child_process.js:682:15)
gyp ERR! stack     at checkPythonVersion (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:79:5)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:46:9
gyp ERR! stack     at which (/usr/local/lib/node_modules/npm/node_modules/which/which.js:30:31)
gyp ERR! stack     at checkPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:36:5)
gyp ERR! stack     at configure (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:31:3)
gyp ERR! stack     at Object.self.commands.(anonymous function) [as configure] (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:66:37)
gyp ERR! System Darwin 14.1.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Volumes/320gb/macbookpro/Desktop/prerender/node_modules/weak
gyp ERR! node -v v0.12.1
gyp ERR! node-gyp -v v1.0.3
gyp ERR! This is a bug in `node-gyp`.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR!     <https://github.com/TooTallNate/node-gyp/issues>
npm ERR! Darwin 14.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "weak"
npm ERR! node v0.12.1
npm ERR! npm  v2.7.3
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 7
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the weak 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 weak
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Volumes/320gb/macbookpro/Desktop/prerender/npm-debug.log

I have tried changing permission of :
sudo chown -R $(whoami) /.node
And a bunch more places but can't get this to work.

I have also removed node and installed it again but no change.

And tried to update node-gyp by:
$ npm explore npm -g -- npm install node-gyp@latest

Is there something more I can do to solve this?

I found a solution, I never tried changing version of npm python. Changing to 2.6 did the trick! YES!!

$ npm config set python /usr/bin/python2.6

@maygupta you're trying to compile C++ that's 0.10 compatible on Node.js 0.12 which has a version of V8 that has a very different API. Either upgrade to newer version(s) of the code that may have updated code for better compatibility or contact the owners of those modules and ask them to get compatible.

Yes it worked fine. Thanks

I have some trouble with a package that depends on weak (I dunno which one is).
I've tried what @nilsi said (npm config set python /usr/bin/python2.6), and double checked the permissions and upgraded node-gyp.
Still getting error on every npm install.
Every new package that is installed goes ok except for not being persisted in package.json which I'm doing manually for the project...
Have you reached any solution (@maygupta)?

npm config set unsafe-perm true
ok...

thank you @unreal0

thanks @unreal0

In my-case it was failing on Linux-mint 19.2, for some reasons on run-time gcc++ was not accessible.
So by installing the build-essentials error was resolved.
PS:

build-essential package is a reference for all the packages needed to compile a Debian packages. It generally includes the GCC/g++ compilers and libraries and some other utilities. Informational for list of build-essential packages can be found on build-essentials

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sentero-esp12 picture Sentero-esp12  路  3Comments

good-idea picture good-idea  路  3Comments

andrewaustin picture andrewaustin  路  3Comments

jhermsmeier picture jhermsmeier  路  3Comments

jlchereau picture jlchereau  路  3Comments