AI Diagnostic Summary

npm ERR! code EEXIST

Well-Documented Error

This error matches known, documented patterns with reliable solutions.

Quick Fix (Most Common Solution)

Seeing "npm ERR! code EEXIST"? This error can be frustrating, but it's usually fixable. It typically affects your development workflow or system. Below you'll find clear, step-by-step solutions to resolve this issue.

High confidence
What This Error Means

npm tried to create a file that already exists.

Frequently documented in developer and vendor support forums.

Based on documented solutions and common real-world fixes.
Not affiliated with browser, OS, or device manufacturers.

New here? Learn why exact error messages matter →

Common Causes
  • Previous failed install left files
  • Concurrent npm operations
  • Cache corruption
How to Fix
  1. Delete node_modules and reinstall
  2. Clear npm cache with npm cache clean --force
  3. Check for running npm processes

Last reviewed: March 2026 How we review solutions

Why This Happens

EEXIST is a POSIX error code meaning "file exists." npm raises this when it attempts to create a file or directory that already exists at the target path and the operation does not allow overwriting. The most common scenario is during global package installation: npm tries to create a symlink in the global bin directory (e.g., /usr/local/bin/eslint) but a file or symlink with that name already exists from a previous installation, a different package manager (yarn, pnpm), or a manual installation. Corrupted node_modules state is the second most frequent trigger—if a previous npm install was interrupted partway through, npm may have created some files but not recorded them in the lockfile, causing the next install to collide with the orphaned files. On Windows, this error also appears when npm tries to create a directory junction that already exists as a regular directory, or when a previous installation left behind read-only files that cannot be overwritten. The error is fundamentally about npm's expectation of a clean target location conflicting with the reality of leftover artifacts from previous operations.

Quick Diagnostic Checklist
  1. Read the error message for the exact file path that already exists
  2. Check if the file is from a previous installation: ls -la
  3. Remove the conflicting file manually and retry npm install
  4. For global installs: check for conflicting symlinks in npm prefix/bin
  5. Clear npm cache and node_modules: npm cache clean --force && rm -rf node_modules
Resolving EEXIST during global install
# Error output:
# npm ERR! code EEXIST
# npm ERR! syscall symlink
# npm ERR! path ../lib/node_modules/typescript/bin/tsc
# npm ERR! dest /usr/local/bin/tsc
# npm ERR! EEXIST: file already exists, symlink

# Step 1: Check what is at the conflicting path
$ ls -la /usr/local/bin/tsc
# lrwxrwxrwx 1 root root 42 Jan 15 /usr/local/bin/tsc -> ../lib/node_modules/typescript/bin/tsc
# ^-- Old symlink exists

# Step 2: Remove the old symlink
$ sudo rm /usr/local/bin/tsc

# Step 3: Retry the installation
$ npm install -g typescript
# Added 1 package in 2s

# Alternative: Force overwrite with --force
$ npm install -g typescript --force
# Overwrites existing files without manual removal

# If the problem is in node_modules (not global):
$ rm -rf node_modules package-lock.json
$ npm install
Edge Cases & Unusual Scenarios

Yarn and npm managing globals simultaneously

If you installed a CLI tool with yarn global add and then try npm install -g for the same tool, the existing yarn symlink conflicts with npm. Uninstall from one package manager before installing with the other: yarn global remove eslint then npm install -g eslint.

nvm switching Node versions with stale globals

Each nvm Node version has its own global node_modules. Switching Node versions and reinstalling globals can leave stale symlinks in the shared bin directory. Run nvm reinstall-packages to migrate global packages cleanly.

Git merge creating duplicate files in node_modules

After merging branches with different dependency trees, node_modules may contain conflicting entries. npm install cannot reconcile these. Delete node_modules entirely and run npm install to rebuild from scratch.

Optional follow-up

Some users ask whether saving fixes for recurring errors would be useful when the same issue appears again.

Was this explanation helpful?

Explanations are based on documented fixes, real-world reports, and common system behavior. GetErrorHelp is independent and not affiliated with software vendors, device manufacturers, or service providers.
Frequently Asked Questions

Why does this happen?

Usually from interrupted installs leaving partial files.

Is it safe to delete node_modules?

Yes, npm install will recreate it.

Is it safe to use --force with npm install?

For global installs, --force overwrites existing files and is generally safe. For local installs, --force skips the cache and overwrites node_modules contents. It should not cause data loss but may mask deeper issues like corrupted state.

Why does EEXIST happen in CI but not locally?

CI environments may cache node_modules between builds. If the cache is stale or was created by a different npm version, the cached files conflict with the new installation. Clear the CI cache or use npm ci instead of npm install, which always starts with a clean node_modules.

How do I prevent EEXIST errors during development?

Use npm ci for clean installs from lockfile, avoid mixing package managers (npm, yarn, pnpm), and never manually create files inside node_modules. If you switch Node versions frequently, use nvm and let it manage global packages per version.

Related Resources

Also Known As

Common Search Variations

Related Errors
Still Stuck?

Paste a different error message or upload a screenshot to get help instantly.

Solutions are based on commonly documented fixes and may not apply in all situations.