The npm: command not found error may appear even if you already have installed npm.
It might look like
bash: npm: command not found
or
sudo: npm: command not found
or
npm: command not found
Solution
Either way the easiest solution is just run the following command:
- if you are logged in as
rootuser
apt-get install npm
- if you are not
rootuser
sudo apt-get install npm
This command will re-install npm and will update is’s path in the system to the correct one.