1

Have spent far too long on this, about to give up.

I know you can go to the official website to update Node but I would like to be able to do it through the command line.

Anyway, when I do npm install npm@latest -g

I get

npm ERR! code EEXIST
npm ERR! path D:\nodejs\npm.cmd
npm ERR! Refusing to delete D:\nodejs\npm.cmd: is outside D:\nodejs\node_modules\npm and not a link
npm ERR! File exists: D:\nodejs\npm.cmd
npm ERR! Move it away, and try again.

I found another solution but did not work for me:

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install --global --production npm-windows-upgrade
npm-windows-upgrade

This works up to this far, then it asks me for which version I want to install. I select it, then I get:

You wanted to install npm 6.14.5, but the installed version is 6.13.4.

A common reason is an attempted "npm install npm" or "npm upgrade npm". As of today, the only solution is to completely uninstall and then reinstall Node.js. For a small tutorial, please see https://github.com/felixrieseberg/npm-windows-upgrade#usage.

Please consider reporting your trouble to https://aka.ms/npm-issues.

I am almost dead. Any help appreciated!

5ecured
  • 181
  • 10
  • On windows I think your best bet is using the installers from the website. On Linux you could use your OS package manager or nvm - there may be a Windows version of nvm so that could be worth looking into – Michael Jun 11 '20 at 07:53
  • Thanks Michael. Alright, for Node, I can go to the official website. However what about npm? – 5ecured Jun 11 '20 at 07:59
  • When upgrading node, you'll also get a newer version of npm. However to upgrade it between node versions on Linux I just do `npm i -g npm` - based on your question this doesn't appear to be an option on windows unfortunately – Michael Jun 11 '20 at 12:30

1 Answers1

1

Have a look at How can I update npm on Windows? or

https://github.com/felixrieseberg/npm-windows-upgrade

  • 1
    Think the op is referring to a windows system – Hoppo Jun 11 '20 at 08:08
  • No worries. Welcome to Stack Overflow. Enjoy the site. – Hoppo Jun 11 '20 at 15:44
  • FYI that question is now locked and the top rated answer (same as yours) is to use a package that hasn't seen a release in years, and whose owner recently archived the repository. We need a new "how should I use node/NPM on Windows in 2021" question, I think. – Coderer Sep 20 '21 at 09:56