I encountered the following error when I tried to install some new packages using 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 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.
May be deleting node_modules
folder and package-lock.json
file and then reinstalling npm
would resolve your issue.
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. 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". 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.
I had a quite similar issue while working with npm. What worked like a charm for me was updating my packages & dependencies for the project, specifically 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.