npm ERR! code ENOTEMPTY while npm install

13,103

Solution 1

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.

Solution 2

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

rm -r node_modules/MODULE

It simply worked!

Solution 3

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.

Share:
13,103

Related videos on Youtube

Sandy
Author by

Sandy

Updated on June 14, 2022

Comments

  • Sandy
    Sandy about 2 years

    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.

    • Oded BD
      Oded BD over 4 years
      you are using old version of node can you update?
  • Kashif Nazar
    Kashif Nazar over 2 years
    This commands works perfectly for general cases. It doesn't do it job complete in case of NPM workspaces.

Related