How to fix npm ERR! code EEXIST npm ERR! EEXIST: file already exists, symlink in npm

npmBEGINNERLOWUpdated Dec 5, 2025ยท 152 views

This error occurs when npm tries to create a symlink but a file or symlink already exists at that location. Usually from a previous npm link, conflicting packages, or broken symlinks.

Quick fix

Fixes npm ERR! code EEXIST npm ERR! EEXIST: file already exists, symlink

npm ERR! EEXIST: file already exists, symlink
npm ERR! /usr/local/bin/my-cli -> /usr/local/lib/node_modules/my-package/bin/cli.js
  1. Identify the conflicting file
  2. Check what's at that path
  3. Remove the conflicting file or symlink
  4. Retry the npm operation
npm โ€” error
npm ERR! EEXIST: file already exists, symlink
npm ERR! /usr/local/bin/my-cli -> /usr/local/lib/node_modules/my-package/bin/cli.js
npm ERR! code EEXIST
npm ERR! EEXIST: file already exists, symlink

What this error means

The EEXIST error means npm is trying to create a symbolic link, but something already exists at the destination path. This commonly happens when: - You previously ran `npm link` and the symlink still exists - Two packages are trying to create the same executable (like two different versions of the same CLI tool) - A broken symlink from a deleted package is left behind npm won't overwrite existing files or symlinks automatically to prevent data loss, so you need to manually remove the conflicting file.

Typical symptoms

  • npm link fails with 'EEXIST: file already exists'
  • npm install -g fails for a package you had linked before
  • Error shows the exact path where the conflict exists
  • Multiple packages providing the same CLI command

Common causes

  1. Previous npm link created a symlink that still exists
  2. Broken/orphaned symlink from deleted package
  3. Two packages trying to create same executable name
  4. Interrupted npm operation left partial files
  5. Manual file created at symlink destination

How to fix "npm ERR! code EEXIST npm ERR! EEXIST: file already exists, symlink"

1Identify the conflicting file

The error message shows the exact path. Note it down:

bash
npm ERR! EEXIST: file already exists, symlink
npm ERR! /usr/local/bin/my-cli -> /usr/local/lib/node_modules/my-package/bin/cli.js

The path before -> is where the conflict exists.

2Check what's at that path

See if it's a file, symlink, or broken symlink:

bash
# Check the file type
ls -la /usr/local/bin/my-cli

# If it's a symlink, see where it points
readlink /usr/local/bin/my-cli

# Check if the symlink target exists
ls -la $(readlink /usr/local/bin/my-cli)
3Remove the conflicting file or symlink

Once you've confirmed it's safe to remove:

bash
# Remove the symlink or file
rm /usr/local/bin/my-cli

# Or if you need sudo
sudo rm /usr/local/bin/my-cli
4Retry the npm operation

Now the operation should succeed:

bash
# For npm link
npm link

# For global install
npm install -g my-package
5Use --force as last resort

If you want npm to overwrite existing files:

bash
npm install --force
npm link --force

Warning: This overwrites files without checking. Use only when you understand what will be overwritten.

Advanced notes

Finding all linked packages: List globally linked packages to see what might conflict:

bash
npm ls -g --depth=0
ls -la $(npm config get prefix)/lib/node_modules

Docker gotcha: Official Node.js Docker images include tools like Yarn pre-installed. If you try to install Yarn again, you'll get EEXIST. Either skip installing it or use --force.

Clean unlink workflow: Always unlink packages properly before removing them:

bash
# In your project first
npm unlink my-package

# Then in the package directory
npm unlink

Frequently asked questions

What does "npm ERR! code EEXIST npm ERR! EEXIST: file already exists, symlink" mean?
The EEXIST error means npm is trying to create a symbolic link, but something already exists at the destination path. This commonly happens when: - You previously ran npm link and the symlink still exists - Two packages are trying to create the same executable (like two different versions of the same CLI tool) - A broken symlink from a deleted package is left behind npm won't overwrite existing files or symlinks automatically to prevent data loss, so you need to manually remove the conflicting file.
How do I fix "npm ERR! code EEXIST npm ERR! EEXIST: file already exists, symlink"?
This error occurs when npm tries to create a symlink but a file or symlink already exists at that location. Usually from a previous npm link, conflicting packages, or broken symlinks.
What causes "npm ERR! code EEXIST npm ERR! EEXIST: file already exists, symlink"?
Previous npm link created a symlink that still exists Broken/orphaned symlink from deleted package Two packages trying to create same executable name
Is the "npm ERR! code EEXIST npm ERR! EEXIST: file already exists, symlink" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading