0

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:.
Asqan
  • 4,319
  • 11
  • 61
  • 100

2 Answers2

1

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

Mansuro
  • 4,558
  • 4
  • 36
  • 76
0

NPM : (without NVM)

To upgrade npm to the latest version on Windows, you can use the following command in the Command Prompt or PowerShell:

npm install -g npm@latest

After running the command, npm will download and install the latest version. Once the installation is complete, you can verify the updated version by running:

npm --version

Hope this helps! enter image description here

Sudir Krishnaa RS
  • 367
  • 1
  • 2
  • 9