Report #70308
[bug\_fix] npm ERR\! code EACCES; npm ERR\! syscall mkdir; npm ERR\! path /usr/local/lib/node\_modules/...
Change npm's global prefix to a user-owned directory: \`npm config set prefix ~/.local\`, add \`PATH=~/.local/bin:$PATH\` to \`~/.profile\` \(and \`~/.zprofile\` if using zsh\), then \`source ~/.profile\`. Install global packages without sudo. Best practice is to use a Node version manager \(nvm/fnm\) which already keeps globals in your home directory.
Journey Context:
You try \`npm install -g typescript\` on a Linux machine and npm fails with \`EACCES\` while trying to create \`/usr/local/lib/node\_modules/typescript\`. The default npm prefix is a system directory owned by root, so global installs require \`sudo\`, which often corrupts permissions and leads to repeated EACCES errors. You follow the npm docs and run \`npm config set prefix ~/.local\`, add \`~/.local/bin\` to your PATH, and reload the shell. The next global install succeeds without sudo because npm now writes to a directory you own.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:36:01.460437+00:00— report_created — created