How to fix npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/npm/bin/npm-cli.js' in npm

npmINTERMEDIATEMEDIUMUpdated Dec 2, 2025· 208 views

Global npm symlinks fail because the bin path is not writable or symlinks are restricted. Use nvm/user prefixes, fix ownership, or adjust Windows symlink policy.

Quick fix

Fixes npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/npm/bin/npm-cli.js'

npm config get prefix
ls -ld $(npm config get prefix)/bin
  1. Check prefix and bin ownership
  2. Use nvm/fnm/asdf or a user prefix (preferred)
  3. Fix ownership if you administer the host
  4. Handle Windows symlink policy
npm — error
npm config get prefix
ls -ld $(npm config get prefix)/bin
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/npm/bin/npm-cli.js'

What this error means

npm creates symlinks in the global bin directory (prefix/bin) for installed binaries. If that directory is root-owned (Linux/macOS) or symlink creation is restricted (Windows without Developer Mode/admin), npm cannot create the link and aborts with EACCES. In CI/Docker, running as non-root with a root-owned prefix causes the same failure.

Typical symptoms

  • npm install -g fails with EACCES on a symlink in prefix/bin
  • Works with sudo/Admin but fails for normal user
  • On Windows, errors when Developer Mode is off or shell is not elevated
  • In CI/Docker, non-root user cannot create links in /usr/local/bin

Common causes

  1. Global prefix/bin owned by root from system Node or sudo installs
  2. Windows symlink policy requires admin/Developer Mode
  3. Existing root-owned npm binary blocks replacement
  4. CI/Docker running as non-root against a root-owned volume
  5. Homebrew-installed Node with mismatched ownership in /usr/local on macOS

How to fix "npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/npm/bin/npm-cli.js'"

1Check prefix and bin ownership
bash
npm config get prefix
ls -ld $(npm config get prefix)/bin

If root-owned, user installs cannot create symlinks there.

2Use nvm/fnm/asdf or a user prefix (preferred)
bash
# nvm example
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \ . "$NVM_DIR/nvm.sh"
nvm install --lts
# user prefix fallback
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
export PATH="$HOME/.npm-global/bin:$PATH"
3Fix ownership if you administer the host
bash
sudo chown -R $(whoami) /usr/local/{lib/node_modules,bin,share}

Do this only on machines you manage (not shared/CI images).

4Handle Windows symlink policy

Enable Developer Mode (Settings → For Developers) or run an elevated PowerShell/CMD for the install. Avoid installing to protected drives; prefer user-scoped Node (nvm-windows) under your profile.

5Retry install cleanly
bash
npm cache clean --force
npm install -g npm

Advanced notes

In Docker/CI, run npm as the user that owns the image filesystem or set prefix to a writable path. On macOS Homebrew installs, ensure /usr/local/bin is writable by the Homebrew user or switch to nvm to keep globals in $HOME. User prefixes avoid root-owned symlink targets entirely.

Frequently asked questions

What does "npm ERR! Error: EACCES: permission denied, symlink '../lib/node_module" mean?
npm creates symlinks in the global bin directory (prefix/bin) for installed binaries. If that directory is root-owned (Linux/macOS) or symlink creation is restricted (Windows without Developer Mode/admin), npm cannot create the link and aborts with EACCES. In CI/Docker, running as non-root with a root-owned prefix causes the same failure.
How do I fix "npm ERR! Error: EACCES: permission denied, symlink '../lib/node_module"?
Global npm symlinks fail because the bin path is not writable or symlinks are restricted. Use nvm/user prefixes, fix ownership, or adjust Windows symlink policy.
What causes "npm ERR! Error: EACCES: permission denied, symlink '../lib/node_module"?
Global prefix/bin owned by root from system Node or sudo installs Windows symlink policy requires admin/Developer Mode Existing root-owned npm binary blocks replacement
Is the "npm ERR! Error: EACCES: permission denied, symlink '../lib/node_module" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading