Error installing node-gyp on ubuntu
Solution 1
This is what worked. You need python 2.6 during the installation.
#!/bin/bash
#On Ubuntu Saucy:
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python2.6
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.6 20
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10
#you can switch between 2.6 & 2.7 using:
sudo update-alternatives --config python
#Btw I installed node using ppa:chris-lea/node.js
https://github.com/TooTallNate/node-gyp/issues/363
Solution 2
If your python version isn't the source of error, check if you have "gyp" installed. This is conflicting with the gyp version in node-gyp.
apt-get remove gyp
https://github.com/TooTallNate/node-gyp/issues/363#issuecomment-32234646
Solution 3
This command sudo apt-get install build-essential
helped in my case.
Solution 4
FWIW, I had a similar problem trying to install Protractor on Ubuntu 14.04 (DigitalOcean). Reinstalling node-gyp fixed the it:
apt-get install node-gyp
Solution 5
on Ubuntu 18, I had to install required build libs to get it working
sudo apt-get install build-essential
Pratik Mandrekar
Updated on October 22, 2020Comments
-
Pratik Mandrekar over 3 years
npm http 200 https://registry.npmjs.org/weak/-/weak-0.2.2.tgz npm http GET https://registry.npmjs.org/bindings npm http 304 https://registry.npmjs.org/bindings > [email protected] install node_modules/weak > node-gyp rebuild Traceback (most recent call last): File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module> sys.exit(gyp.script_main()) AttributeError: 'module' object has no attribute 'script_main' gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/lib/node_modules/npm/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 Linux 3.11.0-15-generic gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! node -v v0.10.15 gyp ERR! node-gyp -v v0.12.1 gyp ERR! not ok npm ERR! [email protected] install: `node-gyp rebuild` npm ERR! Exit status 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 Linux 3.11.0-15-generic npm ERR! command "node" "/usr/bin/npm" "install" "[email protected]" npm ERR! node -v v0.10.15 npm ERR! npm -v 1.3.23 npm ERR! code ELIFECYCLE npm ERR! not ok code 0
I don't have a direct dependency on weak or node-gyp but I guess it is required by my other dependencies (express,phantom,ejs,aws-sdk,moment). Anyone faced such an issue and was able to fix?
-
Hugolpz about 10 yearsWhat does exactly
sudo update-alternatives --config python
? it switch from 2.6 => 2.7 => 2.6 => 2.7 ... ? and how to know which python are we currently using ? -
test30 about 10 yearsyou can evaluate every command line tool to its version by using
which $(readlink -f `which python`)
-
Pratik Mandrekar about 10 yearsYou can figure out the python version in use with the command
python --version
-
Yauhen Yakimovich almost 10 yearsShould be an accepted answer. Downgrading to 2.6 and using PPA is the last resort.
-
pieroxy over 9 yearsI'm having this error when running
npm install
. thegip
package is a dependency ofnpm
, so removing it doesn not solve the issue for me as it removesnpm
as well... I'm on Ubuntu 14.04. -
Róisín Grannell about 9 yearsFor those with similar problems, this resolves the following error for me on Ubuntu. "error: no such option: --no-parallel"
-
Aloy A Sen over 5 yearsin ubuntu 18.04 there are no build-essentials but in earlier editions of ubuntu did not have this problem thanks for your support
-
Erwol over 3 yearsOn a fresh Ubuntu 20 installation I had to run
sudo apt update
before installingbuild-essential
. -
Arthur Ronconi about 2 yearsThe command on Linux Mint 20.3 works fine!
-
Admin about 2 yearsThis answer worked for me on ubuntu 20