When I try to install npm with sudo apt-get install npm
, I got following error:
E: Unable to locate package npm
So, if you only type sudo apt-get install nodejs , it does not install other goodies such as npm. You need to type:
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
or follow the steps below
Installation
sudo apt install curl
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt-get install -y nodejs
sudo apt-get install -y npm
Check installed versions
node --version
npm --version
For Debian Stretch (Debian version 9), nodejs
does not include npm
, and to install it as a separate package, you have to enable stretch-backports
.
echo 'deb http://deb.debian.org/debian stretch-backports main' |
sudo tee /etc/apt/sources.list.d/stretch-backports.list
apt-get update -y
apt-get -t stretch-backports install -y npm
In Buster (Debian 10), npm
is a regular package, so going forward, this should just work. But some of us will still be stuck partially on Stretch boxes for some time to come.
Other solution is that you manually install nodejs bu following this steps:
sudo apt-get install build-essential
wget https://nodejs.org/dist/v16.15.1/node-v16.15.1.tar.gz
tar -xzf node-v16.15.1.tar.gz
cd node-v16.15.1/
./configure
make
sudo make install