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 sadi 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?
Thanks
To resolve this issue I took the following steps
Where [userName] is your Windows user name -- [nodeVer] is your current version of Node, or the one that is giving you issues using NVM
Delete these four files:
C:\Users\[userName]\AppData\Roaming\nvm\[nodeVer]\npm
C:\Users\[userName]\AppData\Roaming\nvm\[nodeVer]\npm.cmd
C:\Users\[userName]\AppData\Roaming\nvm\[nodeVer]\npx
C:\Users\[userName]\AppData\Roaming\nvm\[nodeVer]\npx.cmd
Then in C:\Users\[userName]\AppData\Roaming\nvm\[nodeVer]\node_modules\
, rename the npm
directory to npm_old
Open up your console of choice -- run as admin if necessary -- and navigate into the \npm_old\bin
directory then install NPM at latest (or replace latest w/a version of your choosing) using the command below:
node npm-cli.js i -g npm@latest
Clean-up by deleting the npm_old
directory from earlier. Now all should be good to go...I hope!
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
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