简体   繁体   中英

npm ERR! code ENOTEMPTY while npm install

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.

I had the same error/issue, and I removed the directory.

rm -r node_modules/MODULE

It simply worked!

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.

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.

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

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.

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

  1. del node modules folder
  2. del package-lock.json file
  3. npm i
    OR
  4. npm i --save --legacy-peer-deps

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:

  1. rm -r node_modules

or with superuser privileges

sudo rm -r node_modules . You need to enter your sudo password for this to work

  1. Run npm i to reinstall your dependencies.

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

rm -r node_modules && rm -r dist

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM