Fix “EACCES: permission denied” (Mac, Linux, WSL) – Complete Guide
Environment SetupLast Updated: April 20, 2026 | Author: DevOps Engineering Team | Platforms: Linux / Raspberry Pi / macOS / WSL2
This error is not a system failure. It simply means npm cannot write to system directories — and can be fixed in minutes without using sudo.
Quick Answer: Fix EACCES: permission denied
The error EACCES: permission denied occurs when npm tries to write to a system directory it doesn’t have permission to access. The official OpenClaw installer script is the simplest and most reliable solution — it automatically fixes npm permissions for you.
- ✅ TOP RECOMMENDED: Use the official OpenClaw installer (auto-fixes permissions)
- Configure npm to use a user-writable global directory
- Use a Node version manager like NVM (avoids permission issues entirely)
- ❌ NEVER use
sudo npm install -gas a permanent solution
If you prefer manual configuration, follow npm’s official guide to set up a user-writable directory. This approach is recommended by both npm and OpenClaw documentation.
Quick Fix (Fastest Solution)
- Run the official OpenClaw installer (auto-configures permissions)
- Or configure npm to use a user-writable directory
- Or install NVM (industry standard for Node.js management)
- Restart your terminal session
- Verify installation with
npm list -g openclaw
1-Click Diagnostic Command
# Check current npm prefix
npm config get prefix
# Check if you can write to it
touch $(npm config get prefix)/test-write 2>/dev/null && echo "✅ Writable" || echo "❌ Not writable"
rm -f $(npm config get prefix)/test-write 2>/dev/null
# Check for Node version managers
command -v nvm || echo "NVM not found"
🧠 EACCES: permission denied Fix Map
- Root Cause
- npm trying to write to system directories
- Using sudo npm broke permissions
- No Node version manager installed
- npm prefix misconfigured
- Quick Fix
- Use official OpenClaw installer
- Configure npm user directory
- Install NVM
- Permanent Fix
- Set up NVM for version management
- Configure npm user directory
- Never use sudo npm
- Prevention
- Use version managers
- Configure npm properly
- Avoid sudo with npm
Quick Diagnosis Flow
- ✅ Simplest solution → use official OpenClaw installer
- ✅ Need version management → install NVM
- ✅ Just fix npm → configure user-writable directory
- ✅ Used sudo before → fix existing permissions first
Real-World Causes
- Used
sudo npm install -gin the past (most common) - npm configured to write to
/usr/localor/usr - Node.js installed via system package manager
- Multiple Node.js installations conflicting
- File ownership changed on npm directories
- WSL2 trying to write to Windows file system
- npm install permission denied (global packages)
What Does This Error Mean?
The error EACCES: permission denied means npm does not have permission to write to the directory it’s configured to use for global packages.
Common scenarios:
- Installing global npm packages with
npm install -g - Running
npm installin a restricted directory - OpenClaw installation via npm without proper configuration
Never use sudo npm install -g as a permanent solution. It can cause cascading permission issues and security risks.
npm’s official documentation explicitly warns: Never use sudo npm install -g
Typical Error Output
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
Fix by Platform (Mac / Linux / WSL)
Fix on macOS
Recommended methods: official installer or NVM. Homebrew is also supported:
# Method 1: Official OpenClaw installer (TOP RECOMMENDED)
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash
# Method 2: NVM (industry standard)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.zshrc
nvm install node # Installs latest LTS version
nvm alias default node
# Method 3: Homebrew
brew install node@24
brew link node@24 --overwrite --force
# Verify installation
npm install -g openclaw@latest
Fix on Linux / Raspberry Pi
Recommended methods: official installer or NVM:
# Method 1: Official OpenClaw installer (TOP RECOMMENDED)
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash
# Method 2: NVM (industry standard)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install node # Installs latest LTS version
nvm alias default node
# Verify installation
npm install -g openclaw@latest
Fix on WSL2
⚠️ Important: Always work inside the Linux file system, not Windows:
# Method 1: Official OpenClaw installer (TOP RECOMMENDED)
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash
# Method 2: NVM (industry standard)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install node # Installs latest LTS version
nvm alias default node
# Verify installation
npm install -g openclaw@latest
Step-by-Step Fixes
1. Use Official OpenClaw Installer (TOP RECOMMENDED)
This is the simplest and most reliable method. The installer automatically:
- Detects and installs the correct Node.js version
- Configures npm to use a user-writable directory
- Fixes existing permission issues
- Sets up the OpenClaw daemon
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash
To skip onboarding and just fix permissions:
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash -s -- --no-onboard
This is the official recommended installation method in the OpenClaw documentation.
2. Configure npm to Use User-Writable Directory (Official Method)
This is the official solution recommended by npm:
# Create a directory for global npm packages
mkdir -p ~/.npm-global
# Configure npm to use this directory
npm config set prefix '~/.npm-global'
# Add to PATH (Bash)
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# Add to PATH (Zsh)
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
# Now install OpenClaw without sudo
npm install -g openclaw@latest
This method is documented in npm’s official “Resolving EACCES permissions errors” guide.
3. Install Node.js via NVM (Node Version Manager)
NVM is the industry-standard way to avoid permission issues entirely:
NVM is the industry-standard way to install Node.js without permission issues.
# Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# Reload shell configuration
source ~/.bashrc
# For Zsh users
source ~/.zshrc
# Install latest LTS version of Node.js
nvm install node
nvm use node
nvm alias default node
# Now install OpenClaw without sudo
npm install -g openclaw@latest
4. Fix Existing Permissions (If You Used Sudo)
If you’ve used sudo npm in the past, fix the permissions first:
# Take ownership of npm directories
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules 2>/dev/null || true
sudo chown -R $(whoami) /usr/local/bin 2>/dev/null || true
# Then configure npm user directory
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# Install OpenClaw
npm install -g openclaw@latest
5. Restart Your Terminal
After making changes, always restart your terminal or reload your shell configuration:
# Reload shell configuration (no restart needed)
source ~/.bashrc
# For Zsh users
source ~/.zshrc
# For Fish users
source ~/.config/fish/config.fish
# Or simply close and reopen your terminal
Common Search Variants
- EACCES: permission denied npm
- npm install permission denied
- EACCES permission denied mac
- EACCES permission denied linux
- EACCES permission denied wsl
- npm global install permission denied
- openclaw install permission denied
FAQ (AI & Google Optimized)
Q: What does “EACCES: permission denied” mean?
A: It means npm cannot write to the directory it’s configured to use. This is usually because it’s trying to write to a system directory without proper permissions.
Q: How do I fix “EACCES: permission denied”?
A: The simplest solution is to use the official OpenClaw installer. Alternatively, configure npm to use a user-writable directory or install NVM.
Q: Should I use sudo with npm install?
A: No. Using sudo with npm can cause cascading permission issues and security risks. Configure npm to use a user-writable directory instead.
Q: What’s the best way to avoid npm permission issues?
A: Use a Node version manager like NVM. It installs Node.js in your home directory and avoids permission issues entirely.
Q: Can I fix this without reinstalling Node.js?
A: Yes. Configure npm to use a user-writable directory by following the official npm guide.
Q: Why is npm trying to write to /usr/local?
A: That’s the default prefix for many Node.js installations. Configure npm to use a different directory to avoid permission issues.
Q: Why is using sudo npm not recommended?
A: Using sudo changes the ownership of npm directories to root, causing future permission issues. It also poses a security risk by allowing packages to run with root privileges.
Q: node works locally but not globally?
A: This indicates a PATH configuration issue. Ensure the npm global bin directory is added to your PATH environment variable.
Q: npm works in one terminal but not another?
A: This indicates a shell configuration issue (PATH not loaded in one of the terminals). Restart all terminals or reload your shell configuration.
Summary
EACCES: permission denied occurs when npm tries to write to a system directory without proper permissions.
The simplest and most reliable solution is to use the official OpenClaw installer script,
which automatically configures npm permissions for you.
If you prefer manual configuration, set up a user-writable npm directory or use NVM.
Official Best Practices
- ✅ Never use
sudo npm install -gas a permanent solution - ✅ Use the official OpenClaw installer for automatic permission configuration
- ✅ Use a Node version manager (NVM) to avoid permission issues entirely
- ✅ Configure npm to use a user-writable directory
- ✅ Always restart your terminal after making configuration changes
- ✅ On WSL2, work inside the Linux file system, not Windows
Official References
- npm Official: Resolving EACCES permissions errors
- OpenClaw Official Install Guide
- OpenClaw Official Installer Script