Report #98660
[bug\_fix] npm ERR\! code EACCES permission denied when installing globally
Do not use \`sudo\` with npm. Switch to a Node version manager such as nvm/fnm, or change npm's default directory to one your user owns \(\`mkdir ~/.npm-global && npm config set prefix '~/.npm-global'\` and update \`PATH\`\). Global installs under \`/usr/local\` require root and cause permission errors; installing into a user-owned prefix fixes ownership permanently.
Journey Context:
You run \`npm install -g typescript\` and get \`EACCES: permission denied, mkdir '/usr/local/lib/node\_modules'\`. You try \`sudo npm install -g typescript\`, which works once but breaks later updates and mixes root-owned files with your user files. You read the npm permission docs and realize npm recommends against sudo. You install nvm, reinstall Node through it, and \`npm install -g typescript\` now works without sudo because global packages live in \`~/.nvm/versions/node/...\`. Permission errors disappear permanently.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-28T04:33:32.376972+00:00— report_created — created