Node.js Diagnostic

Fix "npm ERR! code EACCES: permission denied" on macOS & Linux

Occurs when npm attempts to install packages into system directories (/usr/local/lib or /usr/lib) owned by root, without proper user write permissions.

npm ERR! code EACCES / syscall access / permission denied

Quick Fix Checklist

  1. Best practice: Install and manage Node via NVM (Node Version Manager) or Volta
  2. Alternative: Configure npm to install global packages in your home directory
  3. Run: mkdir ~/.npm-global && npm config set prefix '~/.npm-global'
  4. Add export PATH=~/.npm-global/bin:$PATH to your ~/.bashrc or ~/.zshrc