ClawKit Logo
ClawKitReliability Toolkit

Fix β€œnpm install failed for openclaw@latest”

! npm install failed for openclaw@latest
npm error code ELIFECYCLE
npm error errno 1

A failed npm install -g openclaw@latest can have several root causes. Work through the steps below in order β€” most users are unblocked by checking the Node.js version and clearing the npm cache.

Next Step

Fix now, then reduce repeat incidents

If this issue keeps coming back, validate your setup in Doctor first, then harden your config.

Step 1: Check Node.js Version

OpenClaw requires Node.js v22.12.0 or later. Installing on an older version will fail during the postinstall step:

Check and update Node.js
node --version   # Must be v22.12.0+
npm --version

# If outdated, install Node.js v22 LTS:
# Via nvm (recommended):
nvm install 22
nvm use 22

# Or download from nodejs.org (LTS)

Step 2: Clear npm Cache

A corrupted npm cache is a common cause of install failures. Clear it and retry:

Clear cache and reinstall
npm cache clean --force
npm install -g openclaw@latest

Step 3: Fix Network / Registry Errors

If the error message contains ECONNRESET, ETIMEDOUT, or ENOTFOUND registry.npmjs.org:

Fix registry and retry
# Reset to the official npm registry
npm config set registry https://registry.npmjs.org/

# Test registry connection
npm ping

# Retry install
npm install -g openclaw@latest

If you're behind a corporate proxy, set npm config set proxy http://proxy:port and npm config set https-proxy http://proxy:port before retrying.

Step 4: Fix Permissions (Linux / macOS)

On Linux or macOS, you may see EACCES: permission denied when installing globally. The recommended fix is to change the npm prefix to a user-writable directory:

Configure npm to use user-writable prefix
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'

# Add to ~/.zshrc or ~/.bashrc:
export PATH="$HOME/.npm-global/bin:$PATH"

# Reload shell:
source ~/.zshrc

# Now install without sudo:
npm install -g openclaw@latest

Avoid using sudo npm install -g β€” it runs postinstall scripts as root, which is a security risk and can break directory ownership.

Step 5: Run Verbose Install for Diagnosis

If the above steps haven't resolved the issue, run with verbose logging to identify the exact failure point:

Verbose install
npm install -g openclaw@latest --verbose 2>&1 | tee /tmp/openclaw-install.log

# Review the log:
cat /tmp/openclaw-install.log | grep -E "error|ERR|WARN" | head -50

Verify Successful Install

Verify OpenClaw installation
openclaw --version
openclaw gateway status
npx clawkit-doctor@latest

If openclaw --version returns a version number, the install succeeded. Run openclaw gateway start to begin using OpenClaw.

Did this guide solve your problem?