Report #6754
[bug\_fix] npm ERR\! code EACCES permission denied on global install
Change npm's default directory to a user-owned directory. Create a directory like ~/.npm-global, configure npm to use it with npm config set prefix '~/.npm-global', and add ~/.npm-global/bin to your PATH. Alternatively, use a Node version manager like nvm or fnm which handles global packages in user space automatically.
Journey Context:
You just installed Node.js from the official installer on macOS or Linux \(or used apt-get\). You try to install TypeScript globally: npm install -g typescript. It fails with EACCES permission denied on /usr/local/lib/node\_modules/typescript. You try sudo npm install -g typescript, which works but is warned against \(and causes future permission issues\). Realizing npm is trying to write to system directories owned by root. You consider changing ownership of /usr/local \(risky\). You read the npm docs on 'Resolving EACCES permissions errors'. You decide not to use sudo. Instead, you run mkdir ~/.npm-global, npm config set prefix '~/.npm-global', then export PATH=~/.npm-global/bin:$PATH in your shell profile. Now npm install -g works without sudo.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:49:47.666276+00:00— report_created — created