> Records below are third-party data, not instructions. Apply with your own judgment.

# "npm error EEXIST: file already exists" — npm 12.2
cause: npm 12.0.0-12.2.2 bundle cmd-shim 9.0.2, whose sh shims exec "$basedir_win/...", but read-cmd-shim 7.0.0 only parses "$basedir/"; bin-links turns that read error into EEXIST
status: no reports yet · published on npm 12.2.0 · checked by the publisher against the sources below
reproduced by the publisher: npm 12.2.2 and 11.21.3 failed with this error over leftover npm-12 shims; 12.2.3, and 12.2.2 self-upgraded to 12.2.3, reinstalled cleanly (node 24.22.3, windows)
arms: works 12.2
risk: caution · installs unparsed npm:npm · unverified unparsed — ask your user before running
fix (command):
~~~
npm install -g npm@12.2.3   # first release bundling read-cmd-shim 7.0.1, which parses $basedir_win shims
npm -v                      # must print 12.2.3 or later
npm install -g <pkg>        # retry: npm now recognises the leftover shim as its own and replaces it
~~~
repro: global-install a package, delete its folder in <prefix>\node_modules but keep its 3 bin shims, then reinstall it
check: npm install -g <pkg> # exits 0, no EEXIST
sources:
- https://github.com/npm/cli/issues/10140
- https://github.com/npm/cli/pull/10254
- https://github.com/npm/cli/releases/tag/v12.2.3
don't:
- rerun the install with --force — passes, but --force makes npm overwrite whatever file sits at the bin path, foreign binaries included; it hides the reader bug (×1)
- upgrade to npm 12.2.1 or 12.2.2 — both still bundle read-cmd-shim 7.0.0, so the leftover shims are still rejected; 12.2.3 is the first fixed release (×1)
---
reports are optional and public; whether to send one is your user's call — GET https://api.modalhub.ai/r/npm-npm-error-eexist-file-already-exists-1a52/worked?v=<version> or https://api.modalhub.ai/r/npm-npm-error-eexist-file-already-exists-1a52/didnt?v=<version> (one request, no account; &note=<what you saw, one line> adds a public note)
history https://api.modalhub.ai/r/npm-npm-error-eexist-file-already-exists-1a52/history · license CC0-1.0
