Unable to get the latest version of NPM

I am trying to upgrade npm to the latest version since I am using 1.4.28. Using:

npm update -g npm 

I get the following output:

 npm@1.3.26 C:\Users\ck\AppData\Roaming\npm\node_modules\npm-check-updates\node_modules\npm npm@2.1.5 C:\Users\ck\AppData\Roaming\npm\node_modules\ember-cli\node_modules\npm 

and then run

 npm -v 

I see that I'm still using 1.4.28; I can’t understand the result that I got after trying to update, since it is about 1.3.26 and 2.1.5, but I installed 1.4.28 ??

I am in windows and I have already tried to uninstall and reinstall node;

+5
source share
4 answers

from this page: https://github.com/npm/npm/wiki/Troubleshooting

 on windows: Option 1: edit your Windows installation PATH to put C:\Users\<username>\AppDa\Roaming\npm before C:\Program Files (x86)\nodejs. Remember that you'll need to restart cmd.exe (and potentially restart Windows) when you make changes to PATH or how npm is installed. Option 2: remove both of before updating C:\Program Files (x86)\nodejs\npm C:\Program Files (x86)\nodejs\npm.cmd Option 3: navigate to C:\Program Files (x86)\nodejs with cmd.exe and then run the installation without -g: npm install npm on linux: npm install -g npm@latest 
+10
source

To install the latest version of npm, you run:

 npm install -g npm@latest 

You also need to make sure that if you have several npm commands npm , you are using the latter (and not the original npm installed with node ).

Try the following:

 which -a npm 

Based on your findings from the above command, you may need to set the PATH environment variable.

+2
source

Finally, you can upgrade npm. A little unscrupulous guy! I tried to install / upgrade the nom first npm install -g nom@latest , then npm install -g npm@latest in the admin console / Windows.

From 1.4.28 to 2.1.7

Strange, but hey, this works for me!

+1
source

On Windows, you may need to check both your user path and the system path. If in the system path and C:\Users\<username>\AppData\Roaming\npm C:\Program Files\nodejs\; , then npm will reference the version in C:\Program Files\nodejs\; . For me this was a problem and was resolved by setting C:\Program Files\nodejs\; at the end of the user path and removing it from the system path. Remember to restart the terminal after changing the path. Although it is helpful to help me find the problem, none of the baaroz solutions worked in my case.

0
source

Source: https://habr.com/ru/post/1205027/


All Articles