Reputation: 1347
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?
Upvotes: 22
Views: 25718
Reputation: 4691
It will fixed it by forcing the install with --force
npm install -g npm@latest --force
Uninstall old version first
npm uninstall -g your-package-name
install the latest
npm install -g your-package-name@latest
Upvotes: 1
Reputation: 2405
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!
Upvotes: 36
Reputation: 5392
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
Upvotes: 15