Claude Code EACCES Permission Denied (2026)

The Error

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/@anthropic-ai/claude-code
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@anthropic-ai/claude-code'
npm ERR! Please try running this command again as root/Administrator.

The Fix

  1. Set npm’s global prefix to a user-owned directory (never use sudo)
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
  1. Add the new path to your shell profile
# For zsh (macOS default):
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
# For bash:
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
  1. Verify the fix:
npm install -g @anthropic-ai/claude-code
claude --version
# Expected: @anthropic-ai/claude-code/X.X.X

Why This Happens

The default npm global install directory (/usr/local/lib/node_modules) is owned by root on most systems. Running npm install -g as your user account fails because it cannot write to root-owned directories. Using sudo npm install -g creates files owned by root that cause further permission issues later. The correct fix is changing npm’s prefix to a directory your user account controls.

If That Doesn’t Work

  • Alternative 1: Use npx @anthropic-ai/claude-code to run without global install — it downloads and executes in one step
  • Alternative 2: Install via nvm which manages its own prefix: nvm install 20 && npm install -g @anthropic-ai/claude-code
  • Check: Run npm config get prefix and ls -la $(npm config get prefix)/lib/node_modules/ to verify ownership

Prevention

Add to your CLAUDE.md:

Never use sudo for npm install -g. Set npm prefix to ~/.npm-global. Use nvm or volta for Node.js version management to avoid system permission conflicts.

Related articles: Claude Code Command Not Found Fix, NPM Install EACCES Fix, Troubleshooting Hub

This fix also applies if you see variations of this error:

  • Connection or process errors with similar root causes in the same subsystem
  • Timeout variants where the operation starts but does not complete
  • Permission variants where access is denied to the same resource
  • Configuration variants where the same setting is missing or malformed

If your specific error message differs slightly from the one shown above, the fix is likely the same. The key indicator is the operation that failed (shown in the stack trace) rather than the exact wording of the message.

Frequently Asked Questions

Does this error affect all operating systems?

This error can occur on macOS, Linux, and Windows (WSL). The exact error message may differ slightly between platforms, but the root cause and fix are the same. macOS users may see additional Gatekeeper or notarization prompts. Linux users should check that the relevant system packages are installed. Windows users should ensure they are running inside WSL2, not native Windows.

Will this error come back after updating Claude Code?

Updates can occasionally reintroduce this error if the update changes default configurations or dependency requirements. After updating Claude Code, verify your project still builds and runs correctly. If the error returns, reapply the fix and check the changelog for breaking changes.

Can this error cause data loss?

No, this error occurs before or during an operation and does not corrupt existing files. Claude Code’s edit operations are atomic — they either complete fully or not at all. However, if the error occurs during a multi-step operation, you may have partial changes that need to be reviewed with git diff before continuing.

How do I report this error to Anthropic if the fix does not work?

Open an issue at github.com/anthropics/claude-code with: (1) the full error message including stack trace, (2) your Node.js version (node --version), (3) your Claude Code version (claude --version), (4) your operating system and version, and (5) the command or operation that triggered the error.

Configure permissions → Build your settings with our Permission Configurator.

Try it: Paste your error into our Error Diagnostic for an instant fix.