node.js 错误!拒绝删除/编码EEXIST
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46541371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm ERR! Refusing to delete / code EEXIST
提问by Azoulay Jason
I'm just running a simple npm installand i get this error.
我只是运行一个简单的npm install,我得到这个错误。
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.
这是我第一次收到此错误,我不知道该怎么办。
回答by antzshrek
Steps
脚步
- Delete the
node_modulesdirectory completely. - Run
npm installagain.
node_modules彻底删除目录。- 再跑
npm install。
This should help.
这应该有帮助。
回答by yemiOdetola
This was how I solved mine after 'googling' around...
这就是我在“谷歌搜索”后解决我的问题......
- Navigate to the directory your node was installed in
- rename your
npm.cmdandnpmfiles - Try run the installation again
- If successful..delete the files you renamed earlier
npmandnpm.cmd - if not, :( :(
- 导航到您的节点安装的目录
- 重命名您的
npm.cmd和npm文件 - 再次尝试运行安装
- 如果成功..删除您之前重命名的文件,
npm然后npm.cmd - 如果不, :( :(
The cli commands here...in case you don't want to be renaming and stuffs
这里的 cli 命令......以防你不想重命名和东西
cd %ProgramFiles%\nodejs
ren npm.cmd npm2.cmd
ren npm npm2
npm2 install npm@latest -g
del npm2
del npm2.cmd
Rolf-schmidiger
罗尔夫-施密迪格
回答by OArnarsson
Try running npm update -g npmthen run npm iagain.
If that doesn't work maybe npm cache cleanhelps.
尝试运行npm update -g npm然后npm i再次运行。
如果这不起作用,可能会有所npm cache clean帮助。
If that doesn't work either you should consider removing the node_modulesfolder in your application and running npm iagain.
If you still have no luck, I suggest removing the package-lock.jsonand the node_modulesfolder before running npm i.
如果这也不起作用,您应该考虑删除node_modules应用程序中的文件夹并npm i再次运行。
如果你仍然没有运气,我建议在运行之前删除package-lock.json和node_modules文件夹npm i。
回答by Attila123
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/.binalso became regular files.
npm says in the error message, .e.g.
我在 Linux 上遇到了这个问题(npm 是当前最新的 5.6.0),因为我创建了一个 tgz 存档,并且在创建 tgz 存档时我需要 --dereference 一些符号链接(请参阅man tar)(将它们复制到 VM 进行测试) )。这样,很多符号链接node_modules/.bin也变成了常规文件。npm 在错误消息中说,.eg
npm ERR! Refusing to delete /path/to/node_modules/.bin/jest: is outside /path/to/node_modules/jest and not a link
错误!拒绝删除 /path/to/node_modules/.bin/jest:在 /path/to/node_modules/jest 之外而不是链接
回答by userA789
I had a similar error(mine is not @angular),
resolved by deleting and reinstalling node with installer.
我有一个类似的错误(我的不是@angular),
通过使用安装程序删除并重新安装节点来解决。
回答by KT.
I had the same problem and it turned out the problem was that a stray instance of npmwas running somewhere in the background at the same time I was trying to do the install (it was Webpack's npm run serve, to be precise).
我遇到了同样的问题,结果发现问题是npm在我尝试安装的同时,一个流浪实例在后台运行(准确地说是 Webpack 的npm run serve)。
Stopping the running instance resolved the problem.
停止正在运行的实例解决了问题。
回答by Little Brain
I had a similar problem and what seems to have worked is to uninstall npm and reinstall it, making sure to be logged in as the correct user for the reinstall. I think I previously installed npm as root, but was updating a package as a regular (sudo) user.
我遇到了类似的问题,似乎有效的是卸载 npm 并重新安装它,确保以正确的用户身份登录以进行重新安装。我想我之前以 root 用户身份安装了 npm,但以普通(sudo)用户身份更新了一个包。
回答by Kjeld
I had this problem when working on a virtual, encrypted disk. Moving the project to a regular disk solved the problem.
我在处理虚拟加密磁盘时遇到了这个问题。将项目移动到普通磁盘解决了这个问题。

