bash: npm: command not found in Debian 9.3

假如想象 提交于 2019-12-04 04:50:37

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


EDIT

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.

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

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.

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

If nodejs -v shows version, it means nodejs is installed. you need to create soft link for node. Run below commands:

sudo ln -s /usr/bin/nodejs /usr/bin/node

And run

sudo apt-get install -y build-essential

Now check node -v and npm -v. It will show version.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!