Skip to content
Latchkey

npm EEXIST "File exists" - Fix Bin Link Conflicts on Install in CI

EEXIST means npm tried to create a file, directory, or bin symlink that already exists. In CI it is usually a leftover from a stale node_modules, a clashing global link, or a restored cache.

What this error means

npm install/npm ci fails with npm error code EEXIST and a path - frequently a .bin/<cmd> symlink or a package directory. npm refuses to clobber the existing entry.

npm output
npm error code EEXIST
npm error path /usr/local/lib/node_modules/.bin/eslint
npm error EEXIST: file already exists
npm error File exists: /usr/local/bin/eslint
npm error Remove the existing file and try again.

Common causes

A clashing global bin link

A previously global-installed CLI left a bin link that collides with the one npm now wants to create, so npm reports EEXIST rather than overwriting it.

A stale or partial node_modules

A restored or leftover node_modules from an interrupted install can contain entries npm expects to create fresh, causing a conflict.

How to fix it

Remove the conflicting entry and reinstall

Clear stale modules (or the clashing global link) and install clean.

Terminal
rm -rf node_modules
npm ci
# if it is a global bin clash:
npm uninstall -g eslint || rm -f /usr/local/bin/eslint
npm ci

Start from a clean module tree in CI

  1. Prefer npm ci, which removes node_modules before installing.
  2. Do not restore a half-written node_modules from a cancelled run.
  3. Avoid mixing global installs with local CLIs that share a name.

How to prevent it

  • Use npm ci so node_modules starts clean.
  • Avoid global installs that clash with local bins.
  • Do not cache a partial node_modules.

Frequently asked questions

What causes ""npm error code EEXIST""?
A previously global-installed CLI left a bin link that collides with the one npm now wants to create, so npm reports EEXIST rather than overwriting it.
How do I fix "npm error code EEXIST"?
Clear stale modules (or the clashing global link) and install clean.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card