Report #14332
[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=~/.npm-global/bin:$PATH \(add to ~/.bashrc\). Never use sudo with npm. Alternatively, use nvm or fnm to manage Node installations which handle permissions correctly.
Journey Context:
Tried to install a package globally with npm install -g create-react-app. npm tries to write to /usr/local/lib which requires root permission, causing EACCES. As a quick fix, you try sudo npm install -g which appears to work but breaks future local installs with permission errors in the npm cache \(~/.npm\), causes EACCES on subsequent non-sudo installs, and creates security risks. The root cause is npm defaults to system directories \(/usr/local\). The proper fix is reconfiguring npm's prefix to a directory owned by the user \(~/.npm-global\) and adding it to PATH, avoiding sudo entirely and preventing permission corruption. Using nvm \(Node Version Manager\) avoids this entirely by installing Node in user space.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:16:52.293417+00:00— report_created — created