I update npm, it is successfully finished. However, if I ask npm’s version, it still gives the old version:
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:
- Add
/usr/local/bin
to the beginning of thePATH
- 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 Change npm
prefix
/usr/localnpm set prefix /usr/local