Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs installed without npm?

I've just installed nodejs on Debian 7 - by apt-get install nodejs.

Nodejs seems to be working fine, but when I enter "npm" I get "command not found".

"which nodejs" points to "usr/bin" and there it is - nodejs, but there is no npm file, what went wrong?

I found a few solutions, but all of them are related to Macs

BTW, "usr/local/bin" directory is empty I believe everything should install right there?

like image 575
Konrad Avatar asked Jan 15 '15 14:01

Konrad


2 Answers

You have several options.

If you want to continue using Debian packages, you could install npm (debian maintainers have it in a separate package).

apt-get install npm

If you want to just install npm, you can use this modification of Maxime's answer:

curl -L https://npmjs.org/install.sh | sudo sh

(the -L is needed to make curl follow redirects.)

Finally, you may wish to use a different package source. For some Linux distributions (Debian/Ubuntu and RedHat/CentOS), the latest node version provided by the distribution may lag behind the stable version. Here are instructions from NodeSource on getting the latest node, which includes npm and avoids using the problematic nodejs alias

like image 60
Sam Mikes Avatar answered Oct 23 '22 10:10

Sam Mikes


Install npm

curl -L https://npmjs.org/install.sh | sudo sh

(the -L is needed to make curl follow redirects.)

and check version

npm -v
like image 21
MaximeF Avatar answered Oct 23 '22 09:10

MaximeF