Report #5619
[bug\_fix] npm ERR\! code EACCES permission denied on global install
Change npm's default directory to a user-owned directory \(e.g., ~/.npm-global\) and update PATH, or use a Node version manager \(nvm, fnm\) that installs Node in user space.
Journey Context:
Developer tries npm install -g typescript on a fresh Linux/macOS machine. Gets 'EACCES: permission denied, access /usr/local/lib/node\_modules'. Instinctively tries sudo npm install -g, which works but triggers npm warnings about not using sudo. Later, they encounter file ownership issues or cache problems. Searching the error leads to the official npm documentation 'Resolving EACCES permissions errors'. They learn that npm should not need sudo. The recommended paths are: 1\) Use a Node version manager like nvm which installs to ~/.nvm, avoiding system directories entirely. 2\) Manually change npm's prefix to ~/.npm-global, add it to PATH, and reinstall global packages there. They choose nvm for convenience.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:46:02.293368+00:00— report_created — created