npm ERR! Refusing to delete / code EEXIST
Solution 1
Steps
- Delete the
node_modules
directory completely. - Run
npm install
again.
This should help.
Solution 2
This was how I solved mine after 'googling' around...
- Navigate to the directory your node was installed in
- rename your
npm.cmd
andnpm
files - Try run the installation again
- If successful..delete the files you renamed earlier
npm
andnpm.cmd
- if not, :( :(
The cli commands here...in case you don't want to be renaming and stuffs
cd %ProgramFiles%\nodejs
ren npm.cmd npm2.cmd
ren npm npm2
npm2 install [email protected] -g
del npm2
del npm2.cmd
Rolf-schmidiger
Solution 3
Try running npm update -g npm
then run npm i
again.
If that doesn't work maybe npm cache clean
helps.
If that doesn't work either you should consider removing the node_modules
folder in your application and running npm i
again.
If you still have no luck, I suggest removing the package-lock.json
and the node_modules
folder before running npm i
.
Solution 4
For windows users (specific to windows 10) this must solve the problem.
Goto this folder:
C:\Users\[UserName]\AppData\Roaming\
delete or rename the npm
and npm-cache
folders.
This has fixed my problem in Windows.
Solution 5
I got this problem on Linux (npm is the current latest 5.6.0), because I created a tgz archive, and I needed to --dereference some symlinks (see man tar
) when creating a tgz archive (which was them copied to VM for testing). This way a lot of symlinks in node_modules/.bin
also became regular files.
npm says in the error message, .e.g.
npm ERR! Refusing to delete /path/to/node_modules/.bin/jest: is outside /path/to/node_modules/jest and not a link

Azoulay Jason
Hello world ! I'm a young web developer passionate about video games, music, karate and of course IT. I started with classic PHP/MySQL stack, but recently I fell in love with nodeJS. Today I like to play with Angular, React, Scala, Java, PlayFramework, and lot of other great stuff. Let's keep coding and build the future guys.
Updated on July 08, 2022Comments
-
Azoulay Jason 4 months
I'm just running a simple
npm install
and i get this error.npm ERR! path /Users/jasonazoulay/Desktop/fabrick.io/delegation/node_modules/@angular/cli/node_modules/webpack/node_modules/yargs/node_modules/os-locale/node_modules/execa/node_modules/cross-spawn/node_modules/.bin/which npm ERR! code EEXIST npm ERR! Refusing to delete /Users/jasonazoulay/Desktop/fabrick.io/delegation/node_modules/@angular/cli/node_modules/webpack/node_modules/yargs/node_modules/os-locale/node_modules/execa/node_modules/cross-spawn/node_modules/.bin/which: is outside /Users/jasonazoulay/Desktop/fabrick.io/delegation/node_modules/@angular/cli/node_modules/webpack/node_modules/yargs/node_modules/os-locale/node_modules/execa/node_modules/cross-spawn/node_modules/which and not a link npm ERR! File exists: /Users/jasonazoulay/Desktop/fabrick.io/delegation/node_modules/@angular/cli/node_modules/webpack/node_modules/yargs/node_modules/os-locale/node_modules/execa/node_modules/cross-spawn/node_modules/.bin/which npm ERR! Move it away, and try again
This is the first time I get this error and I don't know what to do.
-
antzshrek about 5 yearshave you also tried running
sudo npm install
? -
Azoulay Jason about 5 yearsYes it did the same
-
Trevor almost 3 yearsI also saw this issue when I was hosting a project in a folder that was being synced with Google File Stream. After I moved the project to a "local disk" I was able to run
npm install
-
-
OArnarsson about 5 years@AzoulayJason I just realized. If you are using the newest verison of the angular CLI it is highly recommended to use
yarn
instead ofnpm i
. There is some sort of bug related to npm in the latest version. Hope it helps! -
sigmaxf over 3 yearsThis answer worked for me, but also I had to rename npx.cmd and npx to npx2.cmd and npx2. I also had to run the terminal as administrator.
-
Igor over 3 yearsThis worked for me, too. Had to rename npx and npx.cmd as well as npm and npm.cmd. I then did "npm_ update -g npm" and it worked. Perhaps it had something to do with the fact, that I did not install nodejs via an Installer, but rather extracted it from a zip-file instead.
-
Reza about 3 yearsalso need to rename npx.cmd
-
David Bradley over 2 yearsI deleted the npx files instead of renaming them that worked, new ones were created.
-
David Bradley over 2 yearsThis failed to install after doing this, with missing npm-cli.js. I ended up doing the rename solution below along with removing npx files
-
jasie over 2 yearsthis works, yes, but deletion and installation take a long time. this solution is not optimal.
-
David Klempfner over 2 yearsNow I get 'npm' is not recognized as an internal or external command.
-
David Klempfner over 2 yearsNow I get "Cannot find module C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
-
antzshrek over 2 years@DavidKlempfner you might want to check this other SO answer stackoverflow.com/questions/24721903/…
-
yemiOdetola over 2 years@DavidKlempfner check this stackoverflow.com/questions/20992723/…
-
Zakk Diaz over 2 yearsThis worked for me too. @DavidKlempfner run the command using npm2 now that it's renamed. After that I ran into an issue about Refusing to delete `...\npm\node_modules*\node_modules\.bin* I just manually deleted the .bin folders every time it complained (like twice or 3 times) and it worked.
-
Ruan about 2 yearsAs of [email protected], the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead.
-
Mike T over 1 yeardeleting node_modules will be faster through the command line: rmdir /s /q node_modules
-
Idra about 1 yearjust a question... what happens when u reach step #5... thankfully I was not there, but still... I expect to be there by the standards of modern JS
-
havryliuk 6 monthsI never used yarn and got this error anyway.