bash: npm: command not found in Debian 9.3

Multi tool use


bash: npm: command not found in Debian 9.3
I am using Debian 9.3. (stretch) I cannot run "npm" commands.
Output for node -v
node -v
bash: node: command not found
Output for nodejs -v
nodejs -v
v4.8.2
Output for npm -v
npm -v
bash: npm: command not found
I'm a newbie on Debian and I can't understand what's happening.
- I already reinstall Node.js
- I already tried following the steps of the Official Page.
- I already ran apt-get install npm
Output E: Unable to locate package npm
.
- I was at Debian Testing and have the same error when I was there.
apt-get install npm
E: Unable to locate package npm
Thanks for read and help
- Melt
Possible duplicate of nodejs vs node on ubuntu 12.04
– Claudio Cortese
Feb 23 at 8:15
Possible duplicate of E: Unable to locate package npm
– tripleee
Apr 6 at 10:29
4 Answers
4
Did you installed node js from their website? if that's not the case remove it apt-get remove nodejs
and install it from this link (follow this steps)
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
apt-get remove nodejs
After seing your version i realized that you are running an older version of nodejs... please remove the current nodejs version (V4.8.2) and install it via this link https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
It will give you the last version (mine is V9.2.0) with NPM installed aswell.
Yes I did it from their website initially. :B
– Orlando Cartagena
Feb 23 at 8:44
@OrlandoCartagena can you give the output of
which npm
?– Diogo Jesus
Feb 23 at 9:11
which npm
Also realized now that your nodejs is not up to date ... you are running v4 while the last version is v9.2 ... it might be that
– Diogo Jesus
Feb 23 at 9:16
I reinstall it and still 4.8.2 version.
– Orlando Cartagena
Feb 23 at 18:07
Oh nevermind, I'm stupid .. I was typing " curl -sL deb.nodesource.com/setup_9.x | sudo -E bash -" and on debian is " curl -sL deb.nodesource.com/setup_9.x | bash - " ... after the sudo comand. Thaks a lot ! :B
– Orlando Cartagena
Feb 23 at 18:18
You got an old version of the package (append to me on debian 9)
if you try : apt-cache show nodejs
i think you will see the multiple version proposal.
apt-cache show nodejs
just find the good repository name you want to use for your nodejs install :
Exemple for me it was :
cat /etc/apt/sources.list.d/nodesource.list
deb https://deb.nodesource.com/node_10.x stretch main
deb-src https://deb.nodesource.com/node_10.x stretch main
And force the use of stretch repository during install :
sudo apt install -t stretch nodejs
since install is complete you got all the packages in the expected versions :
$ nodejs -v
v10.7.0
$ npm -v
6.1.0
I had same problem with debian then I tried this and problem solved.
Run this is command
curl -L https://npmjs.org/install.sh | sudo sh
check version
npm -v
You should see this after doing these steps
If nodejs -v
shows version, it means nodejs is installed. you need to create soft link for node. Run below commands:
nodejs -v
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo ln -s /usr/bin/nodejs /usr/bin/node
And run
sudo apt-get install -y build-essential
sudo apt-get install -y build-essential
Now check node -v
and npm -v
. It will show version.
node -v
npm -v
'Node -v' Works know, but 'npm -v' ins't working yet. :B
– Orlando Cartagena
Feb 23 at 8:41
try
sudo apt-get install npm
– HOTAM SINGH
Feb 23 at 10:22
sudo apt-get install npm
'E: Unable to locate package npm' :B
– Orlando Cartagena
Feb 23 at 18:08
RESOLVED .. Thanks for help me ! :B
– Orlando Cartagena
Feb 23 at 18:21
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Visit this link: stackoverflow.com/questions/18130164/… Hope that helps you
– harish durga
Feb 23 at 7:57