Error DictionaryLast Updated: Jan 31, 2026

Fix: EACCES: permission denied

Step-by-step fix for 'EACCES: permission denied' errors when running npm install for OpenClaw.

This page helps you fix permission errors during npm install.


🔴 Raw Error Log (What You Actually See)

You may see one or more of these messages:

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13

Or:

Error: EACCES: permission denied, access '/home/user/.npm'
gyp ERR! stack Error: EACCES: permission denied

If your error looks similar, you are in the right place.


🔍 Why This Happens (Root Cause)

This error occurs when:

  1. npm directories are owned by root instead of your user
  2. You're trying to install packages in a protected system directory
  3. Previous sudo npm install commands created files with wrong ownership

✅ How to Fix It (Step-by-Step)

⚠️ Important: Never use sudo npm install — it creates more permission problems!

Step 1 — Check If You Used sudo Before

If you previously ran sudo npm install, you need to fix ownership first.

Step 2 — Fix npm Directory Ownership (Mac/Linux)

sudo chown -R $USER:$(id -gn $USER) ~/.npm
sudo chown -R $USER:$(id -gn $USER) ~/.config

Step 3 — Fix Project Directory Ownership

Navigate to your OpenClaw project folder and run:

sudo chown -R $USER:$(id -gn $USER) .

Step 4 — Reinstall Dependencies

rm -rf node_modules package-lock.json
npm install

🔎 Verify the Fix

After applying the fix, run:

npm install

✅ Expected Result

The installation completes without EACCES errors:

added 342 packages in 45s

❌ Still Not Working?

Best Practice: Use nvm (Node Version Manager)

Using nvm avoids permission issues entirely:

# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

# Restart terminal, then:
nvm install 18
nvm use 18

# Now npm install works without sudo
npm install

🧭 Advanced Notes

Windows Users:

If you see permission errors on Windows:

  1. Close your terminal
  2. Right-click PowerShell or Command Prompt
  3. Select "Run as Administrator"
  4. Try npm install again

🔗 Related: Common Errors Summary | Error Dictionary

Internal Ref: ERROR_INSTALL_002
ErrorInstallationEACCESPermissionLinuxmacOS