Normal installation would be sudo apt install nodejs
to install Node.js and then sudo apt install npm
to install Node Package Manager. However, upon doing so, npm -v
says 3.5.2
. To upgrade normally, I would do sudo npm install -g npm
, which updates to the latest version (which, at the time of writing this article, is 6.0.1
).
When I do a which npm
, I get /usr/local/bin/npm
, however apt
installs a symlink at /usr/bin/npm
. If I sudo apt purge npm
to remove npm, it still leaves the npm version of npm at /usr/local/bin/npm
, however npm -v
says -bash: /usr/bin/npm: No such file or directory
.
Many articles say to use a PPA to install nodejs, but I think there should be a native way to do this through apt
.
DigitalOcean instructions on installation normally and through PPA: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04
TecAdmin instructions on installation through PPA: https://tecadmin.net/install-latest-nodejs-npm-on-ubuntu/
npm
stored at/usr/bin/npm
? And why is the right version picked up after clearing the bash cache, if both versions remain installed? – temporary_user_name Dec 26 '19 at 04:23echo $PATH
, which shows that/usr/local/bin
will be preferred before/usr/bin
if both targets exist when Bash looks through the path. Bash looks through the path only if it doesn't remember where it found the target before. – krubo Aug 20 '20 at 15:26hash -d npm
then everything was running!!! Thanks alot!!! – Tom Bird Nov 03 '20 at 05:51