What This Error Means
npm attempted to create a file that already exists (EEXIST).
How to Fix It
- Identify the path npm is failing on (look for the last referenced file path in the error output).
- Retry after cleaning local state when safe (common: remove
node_modulesand retry install).
Why It Happens
- The error output usually includes the path that failed, that path points to the real OS-level issue (permissions, disk, locks, or limits).
How to Verify
- Re-run the original command and confirm the filesystem error no longer appears.
- If this is a permission fix, confirm new files in
node_modulesare owned by the expected user.
Manual filesystem checks
- Look for the last referenced filesystem path in the error output and validate that path exists and is writable.
Common CLI Output
npm ERR! code EEXISTnpm ERR! errno EEXIST Prevention Tips
- Keep npm cache and project directories owned by the build user.
- Avoid running project installs as root unless you know exactly why you need it.
- Ensure CI runners have enough disk space and sensible file descriptor limits.
Where This Can Be Triggered
github.com/npm/cli/blob/417daa72b09c5129e7390cd12743ef31bf3ddb83/workspaces/libnpmexec/lib/with-lock.js
Open-source npm CLI code reference tied to this error code. - GitHub
try {
await fs.mkdir(lockPath)
} catch (err) {
if (err.code !== 'EEXIST' && err.code !== 'EBUSY' && err.code !== 'EPERM') {
throw err
}