Report #35500
[bug\_fix] EACCES: permission denied, access '/usr/local/lib/node\_modules'
Do not use sudo. Reinstall Node.js using a version manager \(nvm, fnm, volta\) which manages global packages in user-space directories, or manually change npm's prefix to a user-owned directory \(mkdir ~/.npm-global; npm config set prefix '~/.npm-global'; export PATH=~/.npm-global/bin:$PATH\). The root cause is that npm's default global installation path \(/usr/local\) is owned by root, and installing packages there requires elevated permissions that break future non-sudo npm operations.
Journey Context:
You attempt to install a CLI tool globally with npm install -g @angular/cli or typescript, and the command fails halfway through with "EACCES: permission denied, mkdir '/usr/local/lib/node\_modules/@angular'". You remember that Linux requires sudo for system directories, so you run sudo npm install -g @angular/cli. It appears to work. Later, you try to update the package with npm update -g @angular/cli without sudo, and you get permission denied errors again, or worse, you see warnings that npm is creating directories owned by root in your cache. You search online and find the official npm documentation warning against using sudo. You realize the correct fix is not to change permissions on /usr/local \(which is dangerous\), but to use a Node version manager like nvm or fnm, which installs Node and global packages in your home directory \(e.g., ~/.nvm/versions/node/v20/bin\), completely avoiding system directories. If you can't use nvm, you manually configure npm to use ~/.npm-global as its prefix and add that to your PATH. After switching to nvm, the global install works without sudo, and the permissions issues vanish.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:03:04.624302+00:00— report_created — created