How to fix npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/npm/bin/npm-cli.js' in npm
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- Check prefix and bin ownership
- Use nvm/fnm/asdf or a user prefix (preferred)
- Fix ownership if you administer the host
- Handle Windows symlink policy
npm config get prefixls -ld $(npm config get prefix)/binnpm 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
- 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
- CI/Docker running as non-root against a root-owned volume
- 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'"
npm config get prefix
ls -ld $(npm config get prefix)/binIf root-owned, user installs cannot create symlinks there.
# 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"sudo chown -R $(whoami) /usr/local/{lib/node_modules,bin,share}Do this only on machines you manage (not shared/CI images).
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.
npm cache clean --force
npm install -g npmAdvanced 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
- 📚npm Official Documentation
- 📖npm Docs: Resolving EACCES(Official Docs)
- 💬Stack Overflow: npm global installs require sudo(Stack Overflow)
- 🐙