Skip to content
Advertisement

npm seems not to be updated after updating

I update npm, it is successfully finished. However, if I ask npm’s version, it still gives the old version:

enter image description here

I also tried many other ways to update npm, for all of them it seems to be updated but if I run npm -v I still get the old version. Restarting machine, cleaning cache etc. does not help.

If I run npm, I also see that it is really the old version so it is somehow not updated.


npm is installed using:

sudo apt-get install npm

and my Path:

/bin:/usr/bin:/usr/bin/X11:/usr/local/bin:/usr/bin/TeX/:/usr/sbin:/sbin:/home/builder/bin:.

Advertisement

Answer

When you execute the npm command, or any other command, the shell is going to search in the PATH directories one by one. It will use the first path it encounters containing the command binary.

To find out which path is used, you can use the which command

which npm 

which is probably going to be either /bin or /usr/bin (/usr/bin/X11 being unlikely because it contains X11, the linux windowing system)

In order to use your updated npm version you can:

  1. Add /usr/local/bin to the beginning of the PATH
  2. Copy npm manually to /usr/bin, but that is probably not a good idea since you would need to do that for every npm update
  3. Change npm prefix /usr/local

    npm set prefix /usr/local

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement