Reputation: 2613
I get the below-mentioned error when trying to do NPM install in my Dockerfile. I do delete node_modules before running NPM install still I end up with this error.
npm ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! path /nodejsAction/node_modules/setprototypeof
npm ERR! code ENOTEMPTY
npm ERR! errno -39
npm ERR! syscall rmdir
npm ERR! ENOTEMPTY: directory not empty, rmdir
'/nodejsAction/node_modules/setprototypeof'
Any idea how I can fix this? It seems to work properly on my local mac but on my Jenkins server the script fails.
Upvotes: 43
Views: 105565
Reputation: 546
This problem happened to me yesterday after running npm audit fix
. I could no longer build my Vue project with the npm commands, including npm intall
.
If you look at the bash console after running npm install
, you'll notice that it stops at one of the directories within node_modules
. I solved this problem by removing the offending dependency within package.json
and running npm install
again. It was then back to working normally again.
If it fails again with another module, remove that dependency too. You may also need to look for an alternative dependency that is compatible with your npm
version and/or framework version (if you are using a framework).
Upvotes: 0
Reputation: 169
I encountered the same issue when I was trying to install Shadcn on react 18 once my network connection was broken so when I tried multiple times this issue arose. My solution to the problem was to clear the npm cache using this command
npm cache clean --force
Upvotes: 0
Reputation: 1
Check the terminal for the error it will ask you to rename a particular file in the node_modules You can rename or delete the file and then install your desired package example below (base) Joesephs-Air:qr-code-scanner joseph$ npm install @material-ui/core npm ERR! code ENOTEMPTY npm ERR! syscall rename npm ERR! path /Users/joseph/Documents/qr-code-scanner/node_modules/jss npm ERR! dest /Users/joseph/Documents/qr-code-scanner/node_modules/.jss-HuFTkkaf
in my case the files are in bold, do this instead of deleting and reinstalling the entire node_modules because it may not work
Upvotes: 0
Reputation: 369
Consider deleting package-lock.json. I ran into the same issue deleting it worked.
rm package-lock.json
Upvotes: -1
Reputation: 1
on installing angular (updating to higher versions) just delete node_modules and reinstall
then try again with cli
Upvotes: 0
Reputation: 50462
If there's a rename attempt and it fails, the system throws the error. The rename fails because there's already a backup package with a .module<uuid>
present. You should delete all backup packages. You may need to backup .package-lock.json
mv node_modules/.package-lock.json node_modules/package-lock.json
rm -rf node_modules/.*
mv node_modules/package-lock.json node_modules/.package-lock.json
Upvotes: 0
Reputation: 31
In my case it was with Reactjs and when I was trying to install react-boostrap.
Solution
You should remove the node_modules directory in your project. Run:
or with superuser privileges
sudo rm -r node_modules . You need to enter your sudo password for this to work
Sometimes you may end up with a type error if you're working with React, when you run npm audit fix. Type error like this:
*npm ERR! code ERR_INVALID_ARG_TYPE*
If this is your case, you should replace your react-scripts version in package.json file to ^3.4.1 (as this work for me)
Remove the node_modules again and rerun npm i
It should be fine when you run npm audit fix and you can continue installing your dependency
Upvotes: 3
Reputation: 585
Upvotes: 0
Reputation: 103
In my case, the ENOTEMPTY
followed an ERR_SOCKET_TIMEOUT
. It also carried an instruction to rename the module (uuid
to uuid-<some string>
, nanoid
to nanoid-<some string>
)- renaming led to the same issue, with or without verifying the cache. The fix for this, without having to nuke the cache, was to delete both the source and destination modules
rm -r node_modules/<module>
rm -r node_modules/.<module>-<string suffix>
and then continue the install. Quite similar to an answer given here but deleting just the module wasn't enough for me
Upvotes: 6
Reputation: 983
Error message say that /nodejsAction/node_modules/setprototypeof
is not empty
You have to remove this directory or rename this directory in my case I removed this particular directory
This error show that to Install or update NPM Package you have to remove the particular directory
Upvotes: 0
Reputation: 870
I think the following command might be more appropriate:
rm -r node_modules
This will remove the node_modules
folder in your repository. The command npm install
should work now.
If you are using Webpack, you can also remove the dist
folder using rm -r dist
and re-build your repository.
Upvotes: 58
Reputation: 1488
I had the same error/issue, and I removed the directory.
rm -r node_modules/MODULE
It simply worked!
Upvotes: 18
Reputation: 802
I had the same issue, i did following:
1. Restart system
2. Close VS, VSCode or any editor that has JS files open.
3. Apparently, you might have to do npm install in other directories too before doing it in target folder.
Upvotes: 10