Error installing node-gyp on ubuntu - javascript

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
> weak#0.2.2 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! weak#0.2.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the weak#0.2.2 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" "weak#0.2.2"
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?

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

This command sudo apt-get install build-essential helped in my case.

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

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

on Ubuntu 18, I had to install required build libs to get it working
sudo apt-get install build-essential

Here are the steps to install node-gyp successfully on a Ubuntu system:
1.First of all, install the "make" build tool in Ubuntu with the following commands:
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y;
2. Then you need to install the a proper C/C++ compiler toolchain. We will be installing GCC here with the following commands:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update && \
sudo apt-get install gcc-snapshot -y && \
sudo apt-get update && \
sudo apt-get install gcc-6 g++-6 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave
/usr/bin/g++ g++ /usr/bin/g++-6 && \
sudo apt-get install gcc-4.8 g++-4.8 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave
/usr/bin/g++ g++ /usr/bin/g++-4.8;
3. Install python 2.7 version. (Note: Python 3 is not supported by node-gyp).
sudo apt update
sudo apt upgrade
sudo apt install python2.7 python-pip
4. And finally install, node-gyp npm package:
npm install -g node-gyp
Additional but not important: If you have any atom keyboard-layout related issue with node-gyp then install the following one more package:
sudo apt-get install libxkbfile-dev
Thats all! It should be working fine now.

I faced this issue on Ubuntu 16.04 while trying to install the wikimedia extension mathoid.
I tried everything that was suggested and nothing worked until I did:
sudo apt-get install librsvg2-2 librsvg2-dev

On Ubuntu 10.04, Installing libicu solved my problem.
sudo apt-get install libicu-dev

On Fedora 20, reinstalling gyp fixed this for me.
sudo yum reinstall gyp

I already had build-essential installed. I just had to run:
sudo apt install python

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

If the error is due to " fatal error: dns_sd.h: No such file or directory
32 | #include <dns_sd.h> ",
solve it by
" sudo apt-get install libavahi-compat-libdnssd-dev " , else if it is due to python2 follow
#Manish Jangir method

Fedora Silverblue
rpm-ostree install make automake gcc gcc-c++

Related

Angular CLI Installetion Error for Ubuntu 20.04

sudo npm install -global #angular/cli
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/#angular/cli/bin/ng
npm ERR! dest /usr/bin/ng
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/#angular/cli/bin/ng' -> '/usr/bin/ng'
npm ERR! File exists: /usr/bin/ng
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-10-03T08_55_44_693Z-debug.log
I also use Ubuntu 20.04 and I just had the same problem as you.
Here I just updated the npm package (via synaptic).
After this, sudo npm i -g #angular/cli worked ok.
This point solved my problem, maybe that can help you too.
I had a similar problem on Ubuntu 20.04, after I install nodejs (in my case 14.17 stable) and try install Angular.
I went to the directory /usr/bin and deleted the ng file,
after sudo npm i -g #angular/cli.
So ng --version to see if installed ok.
I hope help yo, bye.

npm unable to install scrypt. node-gyp rebuild

I want to run a blockchain application, but I got this error.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt#6.0.3 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the scrypt#6.0.3 install script.
npm ERR! This is probably not a problem with npm.
There is likely additional logging output above.
I have tried deleting node_modules, npm cache verify and npm install again. I have uninstalled and reinstalled npm and nodejs. My npm version is 6.12.0 and node version v12.13.0
https://github.com/ethereum/web3.js/issues/1066#issuecomment-338841841
From this link:
I've solved this using the following steps
npm install --global --production windows-build-tools
node-gyp configure --msvs_version=2015
npm config set python /path/to/executable/python2.7
npm install web3 --save
And also, I think that you can follow steps to fix node-gyp:
https://github.com/nodejs/node-gyp
Believe or not,
use: sudo npm ...
It worked for me
I know this is an old one, but for anyone hung on this one now, what solved this for me was downgrading to node v10.24.1 & npm v6.14.12. Seems to be an issue with newer node versions.
sudo apt-get update -y
sudo apt-get remove -y gyp
sudo apt-get install -y curl bzip2 build-essential g++ python3 git make gcc gcc-multilib node-gyp
sudo apt-get install -y pkg-config xserver-xorg-dev libxext-dev pkg-config libxi-dev libglu1-mesa-dev libglew-dev
sudo npm install prebuild-install node-pre-gyp node-gyp -g
if show already exist then use --force flag while installing npm package
if then also not solve then try install package using "sudo npm i "
for more information see https://github.com/zodern/meteor-up/issues/683

Can't install babel-cli

I'm getting an error when trying to run:
$babel-node ./server.js
The CLI has been moved into the package babel-cli.
$ npm install -g babel-cli
When I install it and run it again it asks again for it.
Anyone came across this situation? Can't seem to move forward.
>
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "start"
npm ERR! node v5.1.0
npm ERR! npm v3.5.0
npm ERR! code ELIFECYCLE
npm ERR! relay-starter-kit#0.1.0 start: `babel-node ./server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the relay-starter-kit#0.1.0 start script 'babel-node ./server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the relay-starter-kit package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! babel-node ./server.js
npm ERR! You can get their info via:
npm ERR! npm owner ls relay-starter-kit
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/diogo/Projects/cf-ophite/npm-debug.log
Babel Version 6 split some packages.
Did you try to open a new terminal window after
npm install -g babel-cli ?
You can also install version 5 and work as before:
npm install -g babel#5
If this happens after upgrading node, try npm rebuild in your project directory
Another solution is to delete the node_modules folder, and execute npm install again

Problems installing yeoman

I am trying to install yeoman but I am getting the following error messages:
I did install node.js and npm (latest version),now I am doing this
npm install -g yo grunt-cli bower
and
npm install -g yo
but I get the following error messages
npm http GET https://registry.npmjs.org/yo
npm http 200 https://registry.npmjs.org/yo
npm ERR! Error: No compatible version found: yo
npm ERR! No valid targets found.
npm ERR! Perhaps not compatible with your version of node?
npm ERR! at installTargetsError (/usr/share/npm/lib/cache.js:488:10)
npm ERR! at next_ (/usr/share/npm/lib/cache.js:438:17)
npm ERR! at next (/usr/share/npm/lib/cache.js:415:44)
npm ERR! at /usr/share/npm/lib/cache.js:408:5
npm ERR! at saved (/usr/share/npm/lib/utils/npm-registry-client/get.js:147:7)
npm ERR! at Object.oncomplete (/usr/lib/nodejs/graceful-fs.js:230:7)
npm ERR! You may report this log at:
npm ERR! <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR! reportbug --attach /home/siddhartha/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.8.0-19-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "yo"
npm ERR! cwd /home/siddhartha
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.4
npm ERR! message No compatible version found: yo
npm ERR! message No valid targets found.
npm ERR! message Perhaps not compatible with your version of node?
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/siddhartha/npm-debug.log
npm not ok
What is wrong? Is it something with my linux system or with npm or with node.js? I need yeoman up and running soon but I am stuck.
You might try reading the error message:
npm ERR! Perhaps not compatible with your version of node?
Yeoman requires Node >=0.8, but you have Node 0.6:
npm ERR! node -v v0.6.19
Upgrading to latest stable Node should do it.
sudo apt-get install node -y
I am using Ubuntu 12.10.
I had the same issue.
I am going to describe my exact fixes for
npm install -g yo
Yeoman requires node version >= 0.8
Because of permissions, I needed to use sudo npm install -g yo
The steps are:
sudo apt-get install python-software-properties -y
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update -y
sudo apt-get install nodejs -y
sudo npm install -g yo
install nodejs is to update the node to the latest version
add-apt-repository is needed for a better repository to update the nodejs
python-software-properties and software-properties-common are for add-apt-repository
For references:
See https://stackoverflow.com/a/16032073/80353 which explains why you need to install either the python or the software to run add-apt-repository
See https://stackoverflow.com/a/16303380/80353 which inspires the general steps

Error trying to install npm for Node.js

I'm having a stab at learning Node.js and I'm having a few issues when installing NPM (Node Package Manager). I'm pretty sure it's either a permissions thing or folder thing... please note that I've just purchased a Mac (I've used Windows all my life) and I'm pretty unfamiliar with the Mac terminal.
Okay, I went to use the one line install for NPM: curl http://npmjs.org/install.sh | sh and I got an error...
All clean!
! [ -d .git ] || git submodule update --init --recursive
node cli.js rm npm -g -f
node cli.js install -g -f
npm ERR! Could not create /usr/local/lib/node_modules/___npm.npm
npm ERR! error installing npm#1.0.94 Error: EACCESS, Undefined error: 0 '/usr/local/lib/node_modules'
npm ERR! Error: EACCESS, Undefined error: 0 '/usr/local/lib/node_modules'
npm ERR! Report this *entire* log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR!
npm ERR! System Darwin 11.0.0
npm ERR! command "node" "/private/var/folders/z2/f05c8hx105g79drh6r7hr01w0000gn/T/npm.1219/package/cli.js" "install" "-g" "-f"
npm ERR! cwd /private/var/folders/z2/f05c8hx105g79drh6r7hr01w0000gn/T/npm.1219/package
npm ERR! node -v v0.5.9-pre
npm ERR! npm -v 1.0.94
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCESS
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/z2/f05c8hx105g79drh6r7hr01w0000gn/T/npm.1219/package/npm-debug.log
npm not ok
make: *** [install] Error 1
npm ERR! Could not create /usr/local/lib/node_modules/___npm.npm
npm ERR! error installing npm#1.0.94 Error: EACCESS, Undefined error: 0 '/usr/local/lib/node_modules'
npm ERR! Error: EACCESS, Undefined error: 0 '/usr/local/lib/node_modules'
npm ERR! Report this *entire* log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR!
npm ERR! System Darwin 11.0.0
npm ERR! command "/usr/local/bin/node" "/private/var/folders/z2/f05c8hx105g79drh6r7hr01w0000gn/T/npm.1219/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/z2/f05c8hx105g79drh6r7hr01w0000gn/T/npm.1219/package
npm ERR! node -v v0.5.9-pre
npm ERR! npm -v 1.0.94
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCESS
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/z2/f05c8hx105g79drh6r7hr01w0000gn/T/npm.1219/package/npm-debug.log
npm not ok
It failed
there's obviously a folder issue here, perhaps I'm installing in the wrong place, my node folder is at Users/Mike/node, when I try and find out my node path variable using NODE_PATH I get the following error:
Michaels-MacBook-Pro:~ Mike$ node node/NODE_PATH
node.js:203
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module '/Users/Mike/node/NODE_PATH'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Array.<anonymous> (module.js:470:10)
at EventEmitter._tickCallback (node.js:195:26)
Can someone please tell me what I'm doing wrong? Do I need to add the node path like such:
$ export PATH=/path/to/node/0.n.y/bin:${PATH}
$ curl http://npmjs.org/install.sh | sh
Or am I confusing myself?
The permissions on /usr/local require you to use sudo to install NPM, or change your permissions. Of these three, I recommend the third option.
Option #1: Use sudo
(Note that the the creator of NPM advises against using this method)
curl http://npmjs.org/install.sh | sudo sh
Option #2: Change permissions
sudo chmod g+rwx /usr/local
sudo chgrp admin /usr/local
Option #3: Use Homebrew
I recommend installing Homebrew to manage installing *nix tools on OS X (I'd stay away from MacPorts & Fink). Installing Homebrew will set the permissions for /usr/local so you can write to it without sudo. You can then install Node via Homebrew, and then install NPM normally:
brew install node --without-npm
curl http://npmjs.org/install.sh | sh
Use curl http://npmjs.org/install.sh | sudo sh.
Edit: You're using node -v v0.5.9-pre, which is very unstable. Use 0.4.12, the latest stable version.
if you are using windows , it takes some steps , 1) create a file called package.json
{
"name": "hello"
, "version": "0.0.1"
, "dependencies": {
"express": "*"
}
}
where hello is the name of the package and * means the latest version of your dependency
2) code to you project directory and run the following command
npm install
As update for the method #3 on OSX the correct command now is:
brew install node --without-npm
curl https://www.npmjs.org/install.sh | sh
Option #4:
Install node local to the user that needs it.
I should clarify for my purposes I needed npm to install appium on an OSX server running Bamboo for our integrated testing. I only had macports available and rather than installing homebrew to manage just the one package I decided to build it from source and install it local to the bamboo user. Which allowed us to run appium as the bamboo user and made it possible to run our appium tests on Bamboo as a not very privileged user.
This guide from Tom Novelli goes over how to do it. The basic gist is:
# Make the dir to hold the installation of node
cd
mkdir ./local
mkdir sources
# Tell npm about your new non-default directories
vi .npmrc
cd sources
# Get node and do the typical source install procedure
wget http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz
tar xf node-v0.10.29.tar.gz
cd node-v8.10.29/
# Important part is the --prefix
./configure --prefix=~/.local
make
make install
# Make a link so node doesn't get confused
cd
ln -s .local/lib/node_modules .node_modules
# Edit PATH to include ~/.local
vi .bashrc
.npmrc
root = /home/YOUR-USERNAME/.local/lib/node_modules
binroot = /home/YOUR-USERNAME/.local/bin
manroot = /home/YOUR-USERNAME/.local/share/man
.bashrc OR .profile OR whereever you like setting your path
export PATH=$HOME/.local/bin:$PATH
Useful Links
The .npmrc man page useful.
And just in case here's a link to node source.

Categories