$cd ../troubleshooting/
High💻 Platform
Windows EACCES / EPERM — npm Cannot Write to Program Files
// On Windows, running npm install -g openclaw without a user-level prefix tries to write into C:\Program Files\nodejs\node_modules — a protected directory. You get EACCES, EPERM, or 'operation not permitted' even in an elevated PowerShell. The fix is to redirect global packages to %APPDATA%\npm and ensure that path precedes the system Node install in PATH.
diagnose.sh
🔍 Is This Your Issue?
?npm install -g openclaw fails with EACCES or EPERM referencing C:\Program Files\nodejs
?npm config get prefix returns C:\Program Files\nodejs (not %APPDATA%\npm)
?where openclaw shows multiple paths or only Program Files\nodejs
npm_prefix.ps1
✅ Fix 1 — Set npm Prefix to %APPDATA%\npm
No Administrator required after prefix change
# PowerShell — set user-level prefix npm config set prefix "$env:APPDATA\npm" # Verify npm config get prefix # Expected: C:\Users\<you>\AppData\Roaming\npm npm install -g openclaw
user_path.env
✅ Fix 2 — Update User PATH (Order Matters)
User PATH entries must come BEFORE system Node path
# Add to User PATH (Settings → System → About → Advanced → Environment Variables)
# User variables → Path → New:
%APPDATA%\npm
%APPDATA%\npm\node_modules\.bin
# Or PowerShell (current user):
[Environment]::SetEnvironmentVariable(
"Path",
"$env:APPDATA\npm;$env:APPDATA\npm\node_modules\.bin;" + [Environment]::GetEnvironmentVariable("Path","User"),
"User"
)nvm_setup.ps1
✅ Fix 3 — Use nvm-windows or fnm (Recommended Long-Term)
Version manager avoids Program Files entirely
# nvm-windows (https://github.com/coreybutler/nvm-windows) nvm install lts nvm use lts npm config set prefix "$env:APPDATA\npm" npm install -g openclaw # fnm alternative (scoop/choco) fnm install --lts fnm use lts npm install -g openclaw
💡 Pro Tip: Never Run Global npm as Administrator
Installing globally with 'Run as Administrator' masks the prefix problem and creates a second copy under Program Files that shadows your user install. Always fix prefix + PATH, then install without elevation.
🛡️ Prevention checklist
- • Run npm config get prefix after every Node reinstall — it resets on some installers
- • Keep %APPDATA%\npm and %APPDATA%\npm\node_modules\.bin at the front of User PATH
- • Prefer nvm-windows or fnm so Node upgrades never touch Program Files permissions
- • Document your prefix in a dotfile note — corporate images often revert PATH on login
- • Verify with where openclaw — the first hit should be under AppData, not Program Files
❓ FAQ
Q1. Why does npm try to write to Program Files on Windows?
The official Node.js MSI installer places node.exe and a global node_modules folder under C:\Program Files\nodejs. When npm prefix is unset, npm defaults to that directory for global packages. Windows UAC protects Program Files from non-elevated writes — hence EACCES/EPERM for normal users.
Q2. Is it safe to change npm prefix away from Program Files?
Yes — this is Microsoft's recommended pattern for per-user global tools. npm's own docs describe prefix=%APPDATA%\npm for Windows. Node itself stays in Program Files; only globally installed CLIs (openclaw, typescript, etc.) land in your profile.
Q3. I already ran npm as Admin and it 'worked' — do I still need Fix 1?
You likely have openclaw installed twice: one under Program Files (Admin) and one under AppData (user). PATH order decides which runs. Run where openclaw in cmd — if Program Files wins, uninstall the Admin copy and standardize on the user prefix to avoid permission surprises on upgrade.
Q4. Do I need to restart after changing PATH?
Close and reopen PowerShell, cmd, and Windows Terminal — existing sessions cache PATH. VS Code / Cursor integrated terminals also need a full window restart. openclaw --version in a fresh terminal confirms the fix.
Q5. Will WSL or Git Bash behave differently?
WSL uses Linux paths — this guide targets native Windows npm. Git Bash inherits Windows PATH but sometimes mangles %APPDATA% expansion; prefer PowerShell for npm config set prefix. In WSL, install OpenClaw via Linux npm inside the distro instead of sharing Windows node.exe.
Q6. What if corporate policy blocks editing User PATH?
Ask IT to add %APPDATA%\npm to your user PATH via GPO, or use nvm-windows installed in your profile directory (no Admin). Last resort: run OpenClaw via npx without global install — slower startup but no Program Files writes.