[英]npm install error ENOTEMPTY: directory not empty,
I encountered the following error when I tried to install some new packages using npm install
.当我尝试使用
npm install
安装一些新软件包时遇到以下错误。 It happened when I did npm install a-new-package --save
and then delete package-lock.json file afterwards to refresh everything.它发生在我
npm install a-new-package --save
然后删除 package-lock.json 文件以刷新所有内容时。
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /Users/memphismeng/Documents/React Programming/Foot-in-The-Door/mobile/fitd/node_modules/@babel/plugin-proposal-decorators
npm ERR! dest /Users/memphismeng/Documents/React Programming/Foot-in-The-Door/mobile/fitd/node_modules/@babel/.plugin-proposal-decorators-ysLLPQFw
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/memphismeng/Documents/React Programming/Foot-in-The-Door/mobile/fitd/node_modules/@babel/plugin-proposal-decorators' -> '/Users/memphismeng/Documents/React Programming/Foot-in-The-Door/mobile/fitd/node_modules/@babel/.plugin-proposal-decorators-ysLLPQFw'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/memphismeng/.npm/_logs/2021-06-15T18_07_01_162Z-debug.log
What went wrong?什么地方出了错? I also tried
npm audit fix --legacy-peer-deps
but it didn't work.我还尝试
npm audit fix --legacy-peer-deps
但它没有用。
May be deleting node_modules
folder and package-lock.json
file and then reinstalling npm
would resolve your issue.可能会删除
node_modules
文件夹和package-lock.json
文件,然后重新安装npm
将解决您的问题。
So, consider the following commands to apply the above operations:因此,请考虑以下命令来应用上述操作:
remove node_modules
remove package-lock.json
npm install
Obviously, the deleting of package.json is working but this is not always the desired solution.显然,删除 package.json 是有效的,但这并不总是理想的解决方案。 Sometimes you want to run:
有时你想运行:
npm i --package-lock-only //to update package.lock.json
npm audit fix
and then:接着:
npm i
And this should be the first try but, I don't know why it didn't work in my case, which is in react native scenario.这应该是第一次尝试,但是,我不知道为什么它在我的情况下不起作用,这是在反应原生场景中。 It seems like the error "npm install error ENOTEMPTY" is happening when the npm try to write to a folder that is not empty and in this case to "node_modules/@babel/.plugin-proposal-decorators-ysLLPQFw".
当 npm 尝试写入非空文件夹(在本例中为“node_modules/@babel/.plugin-proposal-decorators-ysLLPQFw”时,似乎发生了错误“npm install error ENOTEMPTY”。 If you run:
如果你运行:
rm -rf node_modules/@babel/.plugin-proposal-decorators-ysLLPQFw
And then:接着:
npm i
It should work this time.这次应该可以了。 It should be a cleanup process of react-native though, and when working with web starter kit like CRA it never happened to me before.
不过,这应该是 react-native 的清理过程,并且在使用像 CRA 这样的 web 入门套件时,我以前从未遇到过。
I had a quite similar issue while working with npm.在使用 npm 时,我遇到了一个非常相似的问题。 What worked like a charm for me was updating my packages & dependencies for the project, specifically
react-scripts
.对我来说很有魅力的是更新我的项目包和依赖项,特别是
react-scripts
。
Check what are your outdated packages with:检查您的过时软件包:
npm outdated
Or, follow the code snippets of this guy in medium, that automates the task of check and update your packages one by one.或者,按照这个人的代码片段进行操作,它会自动执行检查和更新包的任务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.