When I try to install npm with sudo apt-get install npm, I got following error:
E: Unable to locate package npm
Why
For Debian Stretch, 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, 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.