Search code examples
node.jsnpmnvm

Can't update npm packages: ERR! code EEXIST


I'm trying to to upgrade npm packages via

npm update -g

But, I get this error:

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

I've googled but none of the solutions work. One said to remove the npm.cmd and npm files from here:

C:\Program Files\nodejs\

I tried that, but it fails as npm is now missing.

That folder, C:\Program Files\nodejs, is actually a shortcut pointing to

C:\Users\lthurman\AppData\Roaming\nvm\v8.11.1

I'm using nvm to manage my node installations, any ideas on how to fix this?


Solution

  • Try doing this below command after deleting the folder C:\Users\xxx\AppData\Roaming\npm, C:\Users\xxx\AppData\Roaming\npm-cache.

    npm install -g npm@latest