Report #26867
[bug\_fix] EACCES: permission denied on global install / Missing write access to /usr/local/lib/node\_modules
Do NOT use \`sudo npm install -g\`. Instead, change npm's default directory to one owned by the current user: \`mkdir ~/.npm-global\`, \`npm config set prefix '~/.npm-global'\`, then add \`export PATH=~/.npm-global/bin:$PATH\` to \`~/.bashrc\` or \`~/.zshrc\`. Restart shell and install globally without sudo. Alternatively, use a Node version manager \(nvm, fnm\).
Journey Context:
Developer on macOS tries to install TypeScript globally: \`npm install -g typescript\`. Gets \`EACCES: permission denied, mkdir '/usr/local/lib/node\_modules/typescript'\`. They try \`sudo npm install -g typescript\`. Installation succeeds but now \`tsc\` fails with permissions errors, and later local \`npm install\` fails because global node\_modules contains root-owned files. Developer searches and finds the official npm documentation "Resolving EACCES permissions errors". They follow it exactly: create \`~/.npm-global\`, set npm prefix, update their \`~/.zshrc\` PATH, source the file. They uninstall the sudo-installed package, then run \`npm install -g typescript\` without sudo. It installs correctly in their home directory, \`tsc\` works, and no permission issues remain.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:29:51.008241+00:00— report_created — created