Updating npm when using nvm-windows

I had to force it :-/

When it came to

node npm-cli.js i -g npm@latest

I'd rather had to use

node npm-cli.js i -g npm@latest --force

probably to overcome a permission error involved in overwriting the "C:\Program Files\nodejs" link.


Several workarounds are available in this Issue on the nvm-windows github repo:

https://github.com/coreybutler/nvm-windows/issues/300

There are examples using DOS, PowerShell, bash, and batch scripts.


This is a duplicate from my answer here: https://stackoverflow.com/a/50955293/491553

Here is how I upgrade npm when running nvm-windows:

cd %APPDATA%\nvm\v14.20.0           # or whatever node version you're using
move npm npm-old
move npm.cmd npm-old.cmd
cd node_modules\
move npm npm-old
cd npm-old\bin
node npm-cli.js i -g npm@latest

And boom, upgraded.


I have windows 10 operating system.

I installed in following way.

cd %APPDATA%\nvm\v8.11.3
move npm 5.6.0
move npm.cmd 5.6.0.cmd
cd node_modules\
move npm 5.6.0
cd 5.6.0\bin
node npm-cli.js i -g npm@latest