I'm using nvm-windows version 1.1.7.
I just installed node 11.9.0.
nvm installs npm version 6.5.0 together with this node version. However, there's npm version 6.7.0 available already.
When I now do npm i -g npm
I get:
npm ERR! path C:\Program Files\nodejs\npm.cmd
npm ERR! code EEXIST
npm ERR! Refusing to delete C:\Program Files\nodejs\npm.cmd: is outside C:\Program Files\nodejs\node_modules\npm and not a link
npm ERR! File exists: C:\Program Files\nodejs\npm.cmd
npm ERR! Move it away, and try again.
I found no way to avoid this.
nvm now has a command to update npm. It's nvm install-latest-npm or npm install --latest-npm .
You can downgrade the npm version by specifying a version in the related commands. If you want to downgrade npm to a specific version, you can use the following command: npm install -g npm@[version. number] where the number can be like 4.9. 1 or 8 or v6.
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
move npx npx-old
move npx.cmd npx-old.cmd
cd node_modules\
move npm npm-old
cd npm-old\bin
node npm-cli.js i -g npm@latest --force
And boom, upgraded.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With