Report #10
[bug\_fix] npm ERR\! code EACCES; npm ERR\! syscall rename; npm ERR\! path /usr/local/lib/node\_modules/...
Do not use \`sudo npm install -g\`. Instead install Node via a version manager \(nvm on Unix, nvm-windows or volta on Windows\) so global modules land in a user-owned directory. Alternatively, change npm's prefix to a user directory \(\`npm config set prefix ~/.npm-global\`\) and add the bin folder to PATH. The root cause is that system-wide Node directories are owned by root and npm lacks permission to mutate them.
Journey Context:
You are setting up a new laptop and immediately run \`sudo npm install -g typescript\` because a tutorial told you to. The next \`npm install -g\` starts failing with EACCES on rename inside \`/usr/local/lib/node\_modules\`. You try \`sudo chown -R $\(whoami\) /usr/local/lib/node\_modules\` and it fixes one install but breaks Homebrew. Then you discover \`nvm\`. You remove the system Node, install nvm, install Node through it, and global packages now live under \`~/.nvm/versions/node/.../bin\`. Your shell PATH picks them up automatically. You uninstall the sudo-installed TypeScript and reinstall without sudo. The deeper lesson: npm's default global prefix on macOS/Linux collides with system permissions; the correct fix is per-user Node installs, not wider sudo usage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-11T22:20:10.632233+00:00— report_created — created