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.
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# Check if it existsls -la project-name# Remove itrm -rf project-name# Retrynpx create-react-app project-namenpm ERR! code EEXISTnpm ERR! EEXIST: file already exists, mkdir 'project-name'
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.
Delete the conflicting directory:
# Check if it exists
ls -la project-name
# Remove it
rm -rf project-name
# Retry
npx create-react-app project-nameWindows:
Remove-Item -Recurse -Force project-nameSimply choose a unique name:
# Instead of:
npx create-react-app my-app
# Use:
npx create-react-app my-app-v2
# or
npx create-next-app my-new-projectIf error shows cache path:
npm cache clean --force
npm cache verify
# Retry
npm initFor stubborn cache issues:
# Linux/macOS
rm -rf ~/.npm
# Windows
Remove-Item -Path "$env:APPDATA\npm-cache" -Recurse -Force
# Reinstall
npm cache verify
npm initKill competing npm processes:
# Linux/macOS
pkill -f npm
pkill -f node
# Windows
taskkill /IM npm.exe /F
taskkill /IM node.exe /FWait a moment, then retry.
Prevention tips:
1. Use unique, descriptive project names
2. Create parent directory first:
mkdir -p ~/projects/new-app
cd ~/projects/new-app
npm init -y3. Check before creating:
[ -d "my-app" ] && echo "Directory exists!" || npx create-react-app my-app4. Regular cache maintenance:
npm cache clean --force # Monthly