Report #39650
[bug\_fix] EACCES permission denied on .npm-global
mkdir ~/.npm-global && npm config set prefix '~/.npm-global' && export PATH=~/.npm-global/bin:$PATH \(or use nvm/fnm instead of system Node\)
Journey Context:
You install Node.js via the macOS/Windows installer or apt-get, then run npm install -g typescript. You get 'EACCES: permission denied, mkdir /usr/local/lib/node\_modules'. You try sudo npm install -g, which appears to work but later causes EACCES errors on npm cache or config files because npm runs postinstall scripts as root, creating root-owned files in your user cache. You try chown -R $\(whoami\) /usr/local, which breaks system updates that expect /usr/local to be root-owned. The root cause is that npm defaults to installing global packages in system directories \(/usr/local on Unix, %AppData% sometimes restricted\). The correct fix is not using sudo, but reconfiguring npm to use a user-writable directory for global installs \(changing prefix to ~/.npm-global\) and adding that to your PATH. Better yet, using nvm or fnn avoids system Node entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T21:01:35.462067+00:00— report_created — created