How to fix npm ERR! code EEXIST npm ERR! EEXIST: file already exists, mkdir 'project-name' in npm

npmINTERMEDIATELOWUpdated Dec 3, 2025ยท 180 views

The EEXIST error occurs when npm tries to create a directory that already exists. This commonly happens during project initialization when a folder with the target name is already present.

Quick fix

Fixes npm ERR! code EEXIST npm ERR! EEXIST: file already exists, mkdir 'project-name'

# Check if it exists
ls -la project-name

# Remove it
rm -rf project-name

# Retry
npx create-react-app project-name
  1. Remove the existing directory
  2. Use a different project name
  3. Clear npm cache
  4. Delete npm cache directory
npm โ€” error
# Check if it exists
ls -la project-name
# Remove it
rm -rf project-name
# Retry
npx create-react-app project-name
npm ERR! code EEXIST
npm ERR! EEXIST: file already exists, mkdir 'project-name'

What this error means

EEXIST (Error EXISTS) is a filesystem error indicating npm tried to create a directory using mkdir() but a file or directory with that name already exists. This commonly occurs when: 1. Running `npx create-react-app my-app` when "my-app" folder exists 2. npm cache has corrupted entries 3. A previous failed installation left partial directories 4. File permission conflicts prevent proper directory operations The error prevents npm from proceeding to avoid accidentally overwriting existing content.

Typical symptoms

  • npm init or create commands fail
  • Error mentions specific directory path
  • Directory may or may not visibly exist
  • Cache-related paths in error message

Common causes

  1. Directory already exists with target name
  2. Previous installation created the directory
  3. npm cache corruption
  4. Concurrent npm processes creating same directory
  5. File exists where directory should be

How to fix "npm ERR! code EEXIST npm ERR! EEXIST: file already exists, mkdir 'project-name'"

1Remove the existing directory

Delete the conflicting directory:

bash
# Check if it exists
ls -la project-name

# Remove it
rm -rf project-name

# Retry
npx create-react-app project-name

Windows:

powershell
Remove-Item -Recurse -Force project-name
2Use a different project name

Simply choose a unique name:

bash
# Instead of:
npx create-react-app my-app

# Use:
npx create-react-app my-app-v2
# or
npx create-next-app my-new-project
3Clear npm cache

If error shows cache path:

bash
npm cache clean --force
npm cache verify

# Retry
npm init
4Delete npm cache directory

For stubborn cache issues:

bash
# Linux/macOS
rm -rf ~/.npm

# Windows
Remove-Item -Path "$env:APPDATA\npm-cache" -Recurse -Force

# Reinstall
npm cache verify
npm init
5Check for running processes

Kill competing npm processes:

bash
# Linux/macOS
pkill -f npm
pkill -f node

# Windows
taskkill /IM npm.exe /F
taskkill /IM node.exe /F

Wait a moment, then retry.

Advanced notes

Prevention tips:

1. Use unique, descriptive project names
2. Create parent directory first:

bash
mkdir -p ~/projects/new-app
   cd ~/projects/new-app
   npm init -y

3. Check before creating:

bash
[ -d "my-app" ] && echo "Directory exists!" || npx create-react-app my-app

4. Regular cache maintenance:

bash
npm cache clean --force  # Monthly

Frequently asked questions

What does "npm ERR! code EEXIST npm ERR! EEXIST: file already exists, mkdir 'proj" mean?
EEXIST (Error EXISTS) is a filesystem error indicating npm tried to create a directory using mkdir() but a file or directory with that name already exists. This commonly occurs when: 1. Running npx create-react-app my-app when "my-app" folder exists 2.
How do I fix "npm ERR! code EEXIST npm ERR! EEXIST: file already exists, mkdir 'proj"?
The EEXIST error occurs when npm tries to create a directory that already exists. This commonly happens during project initialization when a folder with the target name is already present.
What causes "npm ERR! code EEXIST npm ERR! EEXIST: file already exists, mkdir 'proj"?
Directory already exists with target name Previous installation created the directory npm cache corruption
Is the "npm ERR! code EEXIST npm ERR! EEXIST: file already exists, mkdir 'proj" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading