E: Unable to locate package npm
Encountered this in Ubuntu for Windows, try running first
sudo apt-get update
sudo apt-get upgrade
then
sudo apt-get install npm
From the official Node.js documentation:
A Node.js package is also available in the official repo for Debian Sid (unstable), Jessie (testing) and Wheezy (wheezy-backports) as "nodejs". It only installs a nodejs binary.
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
Optional: install build tools
To compile and install native add-ons from npm you may also need to install build tools:
sudo apt-get install -y build-essential
More info: Docs NodeJs