hobenkr hobenkr - 1 year ago 106
Node.js Question

Why do I have two versions of npm

I'm trying to get set up with npm and nodejs on ubuntu server but noticed that somehow I ended up with two versions after running

sudo apt-get install nodejs npm

I know this because when I run
npm -v
, it returns
, while when I run
sudo npm -v
, it returns
. I'd like have this set up properly before I go any further. Does anyone understand why I ended up with two versions? It's my understanding that installing nodejs should also install npm, but this only allows me to run npm with elevated privileges which I know I shouldn't be doing. Can anyone let me know what I'm doing wrong? Thank you.

Answer Source

For some Linux distributions (Debian/Ubuntu and RedHat/CentOS), the latest node version provided by the distribution may lag behind the stable version. Here are instructions from NodeSource on getting the latest node.

Then you can install the latest npm by running sudo npm i -g npm@latest.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download