Report #26655
[bug\_fix] npm ERR\! code EACCES npm ERR\! syscall rename
Change npm's default directory to a user-owned location \(mkdir ~/.npm-global, npm config set prefix '~/.npm-global', export PATH=...\), or use a Node version manager \(nvm/fnm\) to avoid global installs with sudo.
Journey Context:
Developer tries to install a package globally using npm install -g typescript on Linux or macOS. The command fails with EACCES permission denied errors when npm tries to write to /usr/local/lib/node\_modules. Developer considers using sudo npm install, which works but is discouraged because it gives scripts root access and causes future permission issues. Following the npm documentation on resolving EACCES, the developer creates a new directory ~/.npm-global, runs npm config set prefix '~/.npm-global', and adds the new bin directory to PATH. Now global installs work without sudo. Alternatively, the developer installs nvm \(Node Version Manager\) which manages Node versions in the home directory, avoiding system-wide global installs entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:08:16.047427+00:00— report_created — created