Report #56856
[bug\_fix] npm ERR\! code EACCES; npm ERR\! syscall access; npm ERR\! path /usr/local/lib/node\_modules; npm ERR\! errno -13
Change npm's default directory to a user-owned directory: mkdir ~/.npm-global && npm config set prefix '~/.npm-global' && export PATH=~/.npm-global/bin:$PATH. Do not use sudo with npm.
Journey Context:
You try npm install -g typescript on a fresh macOS with Homebrew Node. It fails with EACCES to /usr/local/lib/node\_modules. You think 'I need sudo' and run sudo npm install -g typescript. It works but now you have root-owned files in /usr/local. Later, npm install in a local project fails with permissions errors. Realizing npm should never need sudo, you look up the proper fix. You mkdir ~/.npm-global, run npm config set prefix '~/.npm-global', then add export PATH=~/.npm-global/bin:$PATH to ~/.zshrc. You chown -R $\(whoami\) ~/.npm-global to fix the sudo mess. Now global installs work without sudo because npm writes to your home directory, not system directories.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:55:28.371874+00:00— report_created — created