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 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.
rm -rf node_modules
npm ci
# if it is a global bin clash:
npm uninstall -g eslint || rm -f /usr/local/bin/eslint
npm ciStart from a clean module tree in CI
- Prefer
npm ci, which removesnode_modulesbefore installing. - Do not restore a half-written
node_modulesfrom a cancelled run. - Avoid mixing global installs with local CLIs that share a name.
How to prevent it
- Use
npm ciso node_modules starts clean. - Avoid global installs that clash with local bins.
- Do not cache a partial node_modules.