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.
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 # Monthlynpm error code ENOENT npm error syscall spawn git npm error path git npm error errno -4058 npm error enoent An unknown git error occurred
How to fix "spawn git ENOENT" in npm
npm error code E401 npm error Incorrect or missing password.
How to fix 'E401 Unable to authenticate' errors with npm private registries
npm notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm
npm error code E403 npm error 403 Forbidden - PUT https://registry.npmjs.org/<package>
How to fix 'E403 Forbidden' error in npm