ProjectStack
npm

npm ERR! code ENOTEMPTY — directory not empty

npm tried to remove or rename a directory as part of an install operation but the directory wasn't empty. This can happen during interrupted installs or when files are locked on Windows.

Common causes

  • A previous npm install was interrupted and left partial files behind
  • A file or directory inside node_modules is locked by another process on Windows
  • Concurrent npm installs running at the same time
  • npm is trying to clean up a staging directory that still has contents

How to fix it

  1. Delete node_modules entirely and reinstall: rm -rf node_modules && npm install
  2. On Windows: rmdir /s /q node_modules && npm install
  3. Clear the npm cache: npm cache clean --force
  4. Close all editors and terminals, then delete node_modules and reinstall

Example

npm ERR! code ENOTEMPTY npm ERR! syscall rename npm ERR! path /home/user/project/node_modules/lodash npm ERR! dest /home/user/project/node_modules/.lodash-old npm ERR! errno -39 npm ERR! ENOTEMPTY: directory not empty

Running npm install when a previous interrupted install left partial files in node_modules

Have a different error?

Paste any error message into the Error Translator to get an instant explanation.