How to fix npm ERR! code EEXIST in npm

npmBEGINNERMEDIUMUpdated Dec 6, 2025ยท 275 views

The EEXIST error occurs when npm tries to create a file or directory that already exists. This often indicates a corrupted state that can be resolved by clearing the affected files.

Quick fix

Fixes npm ERR! code EEXIST

rm -rf node_modules
rm package-lock.json
npm install
  1. Remove node_modules and retry
  2. Clear npm cache
  3. Check for running npm processes
  4. Remove specific file mentioned
npm โ€” error
rm -rf node_modules
rm package-lock.json
npm install
npm ERR! code EEXIST

What this error means

EEXIST is a filesystem error indicating npm tried to create something that already exists. This can happen during installation when there are leftover files from previous failed operations, permission issues, or race conditions with concurrent operations. This differs from package conflict errors - EEXIST is specifically about filesystem operations failing due to existing files.

Typical symptoms

  • npm install fails with "file already exists"
  • Previous installation was interrupted
  • Multiple npm processes running
  • Permission denied combined with EEXIST
  • Error points to specific file path
  • node_modules has leftover files

Common causes

  1. Interrupted previous installation
  2. Concurrent npm operations
  3. Corrupted node_modules
  4. Symbolic link conflicts
  5. Global package conflicts
  6. npm cache corruption
  7. Manual file system modifications

How to fix "npm ERR! code EEXIST"

1Remove node_modules and retry

Clean install:

bash
rm -rf node_modules
rm package-lock.json
npm install
2Clear npm cache

Reset npm cache:

bash
npm cache clean --force
npm install
3Check for running npm processes

Ensure no other npm is running:

bash
ps aux | grep npm

# Kill if found
kill <pid>
4Remove specific file mentioned

Delete the conflicting file:

bash
# Error shows: EEXIST /path/to/file
rm -rf /path/to/file
npm install
5Fix global package issues

For global package EEXIST:

bash
# Find global packages location
npm config get prefix

# List and clean
npm ls -g --depth=0
npm uninstall -g problematic-package
npm install -g problematic-package
6Check symlink issues

Resolve symlink problems:

bash
# Find broken symlinks in node_modules
find node_modules -type l ! -exec test -e {} \; -print

# Remove them
find node_modules -type l ! -exec test -e {} \; -delete

Advanced notes

In CI/CD, always start with clean node_modules or use npm ci which clears it automatically. Don't run multiple npm installs in parallel on the same directory. File locking issues can occur on Windows with antivirus scanning node_modules. For persistent issues, check filesystem health (fsck on Linux).

Frequently asked questions

What does "npm ERR! code EEXIST" mean?
EEXIST is a filesystem error indicating npm tried to create something that already exists. This can happen during installation when there are leftover files from previous failed operations, permission issues, or race conditions with concurrent operations. This differs from package conflict errors - EEXIST is specifically about filesystem operations failing due to existing files.
How do I fix "npm ERR! code EEXIST"?
The EEXIST error occurs when npm tries to create a file or directory that already exists. This often indicates a corrupted state that can be resolved by clearing the affected files.
What causes "npm ERR! code EEXIST"?
Interrupted previous installation Concurrent npm operations Corrupted node_modules
Is the "npm ERR! code EEXIST" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading