Fix 'Failed to start CLI: Error: spawn npm ENOENT' in OpenClaw
See the 'spawn npm ENOENT' error? It means Node/NPM is missing or not in your PATH. Here is the instant fix for Mac, Linux, and Docker.
TL;DR: The Instant Fix
The Problem: OpenClaw can't find
npmto execute CLI commands. Either Node.js isn't installed, or it's not in your PATH.The Error:
Error: spawn npm ENOENTThe Solution:
- Check if Node is installed:
node --version- Add npm to PATH: Export Node binary directory to PATH
- Or: Use a VPS where everything is pre-configured
Deploy on Vultr (H100/A100 Ready) (High Availability & Limited Time Promotion for new accounts)
The Log: What You're Seeing
The Error:
[2026-02-04 10:23:45] INFO: Starting OpenClaw agent...
[2026-02-04 10:23:45] ERROR: Failed to start CLI
Error: spawn npm ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:477:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
[Agent] Unable to execute tool: run_command
[System] CLI initialization failed
Context: This error occurs when OpenClaw tries to execute npm commands but can't find the npm executable.
Observed Behavior: OpenClaw starts loading, then immediately crashes when it tries to use any CLI-based tool.
Why This Happens (It's Not a Bug)
This is an Environment Configuration Mismatch.
OpenClaw's CLI tools assume:
- Node.js is installed on your system
npmis accessible via PATH- Permissions allow executing subprocesses
But your setup has:
- Node.js not installed OR
- Node not in PATH OR
- Wrong Node version (< 18.x)
The error ENOENT means "Error NO ENTry" ā the system cannot find the file you asked it to execute.
Common Scenarios
| Scenario | Why It Fails |
|---|---|
| Fresh OS install | Node.js not installed |
| Multiple Node versions | Wrong Node version in PATH |
| Docker container | Node not installed in container |
| Windows | Node installed but PATH not updated |
| macOS with Homebrew | Homebrew binaries not in PATH |
ā ļø Critical Crash Warning
If this step fails not with an error message, but with a sudden crash or
spawn EINVAL, do not keep retrying. Your environment may be corrupted. Go to the Spawn EINVAL Decision System ā
Solution A: Verify Node Installation
Step 1: Check if Node is installed
# Check Node version
node --version
# Check npm version
npm --version
# Check which npm is being used
which npm
Expected Output:
v18.x.x or higher
9.x.x or higher
/usr/local/bin/npm (or similar)
If you get command not found: Node.js is not installed.
Step 2: Install Node.js (if missing)
# macOS (Homebrew)
brew install node
# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# Windows
# Download from: https://nodejs.org/
Step 3: Add Node to PATH (if installed but not found)
# Find your Node installation
# Common locations:
# macOS Homebrew: /opt/homebrew/bin/
# Linux: /usr/local/bin/ or /usr/bin/
# Windows: C:\Program Files\nodejs\
# Add to PATH (macOS/Linux)
export PATH="/opt/homebrew/bin:$PATH"
# Make it permanent (add to ~/.zshrc or ~/.bashrc)
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Solution B: The Docker Fix
If you're running OpenClaw in Docker, Node.js must be installed inside the container.
Dockerfile example:
FROM node:18-alpine
# Install OpenClaw
RUN npm install -g openclaw
# Set working directory
WORKDIR /app
# This ensures npm is available
CMD ["openclaw"]
Verify npm is in container:
# Build and run
docker build -t openclaw-cli .
docker run -it openclaw-cli sh
# Inside container, verify:
which npm
# Should output: /usr/local/bin/npm
Solution C: The VPS Fix (Recommended)
Why debug environment issues when you can have everything pre-configured?
Local vs Cloud Comparison
| Issue | Local Setup | Cloud VPS (Vultr) |
|---|---|---|
| Node.js | Manual install required | Pre-installed |
| npm in PATH | Requires shell config | Already configured |
| Version conflicts | nvm needed | Isolated environment |
| Setup Time | 30-60 minutes | 60 seconds |
| Ongoing maintenance | You manage it | Host manages it |
The ROI Calculation
Local "Free" Setup:
- Install Node.js: 10 minutes
- Debug PATH issues: 20 minutes
- Handle version conflicts: 30 minutes
- Total time: 60 minutes Ć $50/hr = $50
Cloud Setup:
- Create instance: 2 minutes
- Everything pre-installed
- Total time: 2 minutes = $0
The "Survival" Recommendation
Stop debugging environment issues.
Every hour you spend fixing PATH, installing Node versions, or debugging Docker is an hour you're not shipping.
The smart choice: Deploy on a VPS where everything just works.
Deploy on Vultr (H100/A100 Ready) (High Availability & Limited Time Promotion for new accounts)
Complete Working Example
Verified Configuration
# 1. Verify Node installation
node --version # Should be v18+
npm --version # Should be v9+
# 2. Verify npm in PATH
which npm # Should show path to npm
# 3. Start OpenClaw
openclaw start
# Success: [INFO] CLI initialized successfully
Docker Configuration
# docker-compose.yml
version: '3.8'
services:
openclaw:
image: node:18-alpine
working_dir: /app
command: npx openclaw start
volumes:
- ./data:/app/data
environment:
- NODE_ENV=production
FAQ
Q: I have Node installed but still get ENOENT?
A: Node is installed but not in your PATH. Run which npm to see if it's found. If not, add Node's binary directory to your PATH environment variable.
Q: What Node version does OpenClaw need?
A: OpenClaw requires Node.js 18.x or higher. Older versions may have compatibility issues with CLI tool execution.
Q: Can I use nvm to manage Node versions?
A: Yes, but ensure nvm is loaded in your shell before starting OpenClaw. Add source ~/.nvm/nvm.sh to your shell config if needed.
Q: Why does this happen in Docker?
A: Your Docker image doesn't have Node.js installed. Use a Node-based image (like node:18-alpine) or install Node in your Dockerfile.
Q: Is a VPS worth it just to avoid environment issues?
A: Yes. VPS instances come with Node.js pre-installed and properly configured. You save hours of environment setup and ongoing maintenance.
Related Fixes
-
Fix OpenClaw CUDA OOM Errors - VRAM optimization guide
-
Fix OpenClaw Slow Inference - Bandwidth explained
-
Fix OpenClaw JSON Parsing Errors - DeepSeek thinking tags
-
Running OpenClaw with DeepSeek R1: Complete Guide - Setup and configuration
Bottom Line: This isn't an OpenClaw bug. It's an environment configuration issue.
Fix it locally in 30 minutes, or deploy on a VPS in 30 seconds.
Deploy on Vultr (H100/A100 Ready) (High Availability & Limited Time Promotion for new accounts)
Still Stuck? Check Your Hardware
Sometimes the code is fine, but the GPU is simply refusing to cooperate. Before you waste another hour debugging, compare your specs against the Hardware Reality Table to see if you are fighting impossible physics.
Bookmark this site
New fixes are added as soon as they appear on GitHub Issues.
Browse Error Index ā