Complete installation guide for OpenClaw AND OpenCode across all platforms. Includes how to download and use this skill in OpenCode, plus operations/maintenance guide with user data collection.
This skill provides comprehensive installation instructions for OpenClaw across all supported platforms. OpenClaw is a powerful AI-powered coding assistant that runs in your terminal.
⚠️ VERIFY THIS TABLE against official docs before publishing.
Choose your platform for the fastest installation path:
| Platform | Command | Source |
|---|---|---|
| Windows | winget install openclaw or npm install -g openclaw | https://docs.openclaw.ai/install |
| macOS | brew install openclaw or npm install -g openclaw | https://docs.openclaw.ai/install |
| Linux | npm install -g openclaw | https://docs.openclaw.ai/install |
| Docker | See docs/docker.md | https://docs.openclaw.ai/install/docker |
⚠️ CORRECTION NEEDED: Previous version said v18+, but official docs say Node 22+ required.
⚠️ UNVERIFIED: The following numbers are NOT from official docs — verify before publishing.
⚠️ CORRECTION: The official docs recommend the installer script as the primary method for ALL platforms. Only use npm/pnpm if you already have Node 22+.
macOS / Linux / WSL2:
curl -fsSL https://openclaw.ai/install.sh | bash
Windows (PowerShell):
iwr -useb https://openclaw.ai/install.ps1 | iex
Source: https://docs.openclaw.ai/install (accordion "Installer script")
⚠️ CORRECTIONS NEEDED: Check against official docs.
# Install via Windows Package Manager
winget install openclaw
# Verify installation
openclaw --version
Source: https://docs.openclaw.ai/install/node shows
winget install OpenJS.NodeJS.LTSfor Node; OpenClaw via winget needs verification.
# Install Node.js first (if not using installer script)
winget install OpenJS.NodeJS.LTS
# Install globally
npm install -g openclaw
# Verify installation
openclaw --version
Source: https://docs.openclaw.ai/install (npm install -g openclaw@latest) — confirmed.
# Install Chocolatey first if not available
# Then install OpenClaw
choco install openclaw
# Verify
openclaw --version
# Set API key (PowerShell)
$env:ANTHROPIC_API_KEY="your-api-key-here"
# Or permanently in user environment
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "your-api-key-here", "User")
# Create workspace directory
mkdir $env:USERPROFILE\.openclaw\workspace
See: docs/windows.md for detailed Windows instructions.
⚠️ CORRECTION: The official docs recommend the installer script as the primary method for ALL platforms. Only use npm/pnpm if you already have Node 22+.
macOS / Linux / WSL2:
curl -fsSL https://openclaw.ai/install.sh | bash
Windows (PowerShell):
iwr -useb https://openclaw.ai/install.ps1 | iex
Source: https://docs.openclaw.ai/install (accordion "Installer script")
⚠️ CORRECTIONS NEEDED: Check against official docs.
# Install Homebrew if not present
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Node.js 22+ (required)
brew install node
# Install OpenClaw
brew install openclaw
# Verify installation
openclaw --version
Source: https://docs.openclaw.ai/install + https://docs.openclaw.ai/install/node confirms Homebrew as macOS method.
# Install Node.js 22+ via Homebrew
brew install node
# Install OpenClaw globally
npm install -g openclaw
# Verify installation
openclaw --version
Source: https://docs.openclaw.ai/install (npm method) — confirmed.
# Add to ~/.zshrc or ~/.bash_profile
export ANTHROPIC_API_KEY="your-api-key-here"
# Reload shell
source ~/.zshrc
# Create workspace
mkdir -p ~/.openclaw/workspace
See: docs/macos.md for detailed macOS instructions.
⚠️ CORRECTION: Official docs recommend installer script as primary method.
curl -fsSL https://openclaw.ai/install.sh | bash
Source: https://docs.openclaw.ai/install (accordion "Installer script")
# Install Node.js 22+ via NodeSource (if needed)
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
# Install OpenClaw
sudo npm install -g openclaw
openclaw onboard --install-daemon
Source: https://docs.openclaw.ai/install (accordion "npm / pnpm")
# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
# Install Node.js 22
nvm install 22
nvm use 22
# Install OpenClaw
npm install -g openclaw
# Add to ~/.bashrc or ~/.zshrc
export ANTHROPIC_API_KEY="your-api-key-here"
# Reload
source ~/.bashrc
# Create workspace with proper permissions
mkdir -p ~/.openclaw/workspace
chmod 700 ~/.openclaw
See: docs/linux-ubuntu.md for detailed Linux instructions.
⚠️ Official docs prefer the installer script + Node 22+.
# Update system
sudo apt update && sudo apt upgrade -y
# Install Node.js 22 (ARM64)
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
# Install OpenClaw
npm install -g openclaw@latest
openclaw onboard --install-daemon
# Increase swap (if needed)
sudo dphys-swapfile swapoff
sudo sed -i 's/CONF_SWAPSIZE=.*/CONF_SWAPSIZE=2048/' /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
# Set memory limit for Node.js
export NODE_OPTIONS="--max-old-space-size=2048"
See: docs/raspberry-pi.md for detailed Raspberry Pi instructions.
⚠️ CORRECTION: Official docs recommend using
docker-setup.shfrom the OpenClaw repo for the Docker gateway flow.
./docker-setup.sh
Source: https://docs.openclaw.ai/install/docker ("Quick start (recommended)")
openclaw/openclaw:latest are UNVERIFIED in this skill unless confirmed by the official docs page.docs/docker.md in this skill (now includes Sources) and the official page above.# Clone and build
git clone https://github.com/openclaw/openclaw.git
cd openclaw
docker build -t openclaw-custom .
See: docs/docker.md for detailed Docker instructions. Files: docker/docker-compose.yml, docker/Dockerfile
# SSH into your VPS
ssh root@your-vps-ip
# Update system
apt update && apt upgrade -y
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs
# Install OpenClaw
npm install -g openclaw
# Create dedicated user (security best practice)
useradd -m -s /bin/bash openclaw
su - openclaw
# Configure API key
echo 'export ANTHROPIC_API_KEY="your-key"' >> ~/.bashrc
source ~/.bashrc
# Create workspace
mkdir -p ~/.openclaw/workspace
# /etc/systemd/system/openclaw.service
[Unit]
Description=OpenClaw AI Assistant
After=network.target
[Service]
Type=simple
User=openclaw
WorkingDirectory=/home/openclaw/.openclaw/workspace
Environment=ANTHROPIC_API_KEY=your-key
ExecStart=/usr/bin/openclaw --daemon
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
# Enable and start service
sudo systemctl daemon-reload
sudo systemctl enable openclaw
sudo systemctl start openclaw
See: docs/vps.md for detailed VPS deployment instructions.
OpenClaw supports multiple AI providers:
# Anthropic (default)
export ANTHROPIC_API_KEY="sk-ant-..."
# OpenAI compatible
export OPENAI_API_KEY="sk-..."
export OPENAI_BASE_URL="https://api.openai.com/v1"
# Azure OpenAI
export AZURE_OPENAI_API_KEY="..."
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com"
# Local models (Ollama)
export OLLAMA_HOST="http://localhost:11434"
Create ~/.openclaw/config.json:
{
"defaultModel": "claude-sonnet-4-20250514",
"workspace": "~/.openclaw/workspace",
"theme": "dark",
"editor": "code",
"git": {
"autoCommit": false,
"signCommits": true
},
"logging": {
"level": "info",
"file": "~/.openclaw/logs/openclaw.log"
}
}
Place custom skills in:
~/.openclaw/skills/./skills/ (in your project)/usr/share/openclaw/skills/# Check version
openclaw --version
# Check configuration
openclaw config --list
# Run self-test
openclaw doctor
# Test API connection
openclaw test-api
OpenClaw v1.x.x
Node.js v20.x.x
npm v10.x.x
Configuration:
API Key: [CONFIGURED]
Workspace: ~/.openclaw/workspace
Skills: 15 loaded
All systems operational!
Cause: PATH not configured or installation incomplete.
Solutions:
# Check if npm global bin is in PATH
npm config get prefix
# Add to PATH in ~/.bashrc or ~/.zshrc:
export PATH="$(npm config get prefix)/bin:$PATH"
# Or reinstall with sudo
sudo npm install -g openclaw
Cause: Environment variable not exported.
Solutions:
# Temporary (current session)
export ANTHROPIC_API_KEY="your-key"
# Permanent (add to shell config)
echo 'export ANTHROPIC_API_KEY="your-key"' >> ~/.bashrc
source ~/.bashrc
# Windows PowerShell (permanent)
[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "your-key", "User")
Cause: npm global directory permissions issue.
Solutions:
# Option 1: Fix permissions
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
# Option 2: Use nvm (recommended)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install --lts
npm install -g openclaw
# Option 3: Configure npm to use different directory
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install -g openclaw
Cause: OpenClaw requires Node.js 18+.
Solutions:
# Check version
node --version
# Update via nvm
nvm install 20
nvm use 20
# Update via package manager (Ubuntu)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# Update via Homebrew (macOS)
brew upgrade node
Cause: API key invalid or rate limited.
Solutions:
# Verify API key format
echo $ANTHROPIC_API_KEY | head -c 10
# Should start with "sk-ant-"
# Test API directly
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-20250514","max_tokens":10,"messages":[{"role":"user","content":"Hi"}]}'
# If rate limited, wait or upgrade plan
Cause: Corrupted installation or dependency issues.
Solutions:
# Clear npm cache and reinstall
npm cache clean --force
npm uninstall -g openclaw
npm install -g openclaw
# If using nvm, try fresh Node.js install
nvm install 20 --reinstall-packages-from=current
Cause: UID/GID mismatch between host and container.
Solutions:
# Run with current user
docker run -it --rm \
--user $(id -u):$(id -g) \
-v $(pwd):/workspace \
openclaw/openclaw:latest
# Or fix permissions on host
chmod -R 777 ./workspace # Less secure
Cause: PowerShell execution policy.
Solutions:
# Check policy
Get-ExecutionPolicy
# Allow scripts (run as Administrator)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# Or use cmd.exe instead
cmd /c openclaw
Cause: Insufficient RAM for Node.js operations.
Solutions:
# Increase swap
sudo dphys-swapfile swapoff
sudo sed -i 's/CONF_SWAPSIZE=.*/CONF_SWAPSIZE=2048/' /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
# Limit Node.js memory
export NODE_OPTIONS="--max-old-space-size=1536"
Cause: Outdated CA certificates or proxy interference.
Solutions:
# Update CA certificates (Linux)
sudo apt install ca-certificates
sudo update-ca-certificates
# Bypass (not recommended for production)
export NODE_TLS_REJECT_UNAUTHORIZED=0
# If behind proxy
export HTTP_PROXY="http://proxy:port"
export HTTPS_PROXY="http://proxy:port"
npm config set proxy http://proxy:port
npm config set https-proxy http://proxy:port
# Full system diagnostic
openclaw doctor --verbose
# Check network connectivity
openclaw test-connection
# Verify skills loading
openclaw skills --list
# Check workspace permissions
openclaw workspace --check
# Generate debug report
openclaw debug-report > ~/openclaw-debug.txt
[openclaw]When reporting issues, include:
openclaw doctornode --version)npm --version)# npm
npm update -g openclaw
# Homebrew
brew upgrade openclaw
# Docker
docker pull openclaw/openclaw:latest
# Check current vs latest
openclaw --version
npm show openclaw version
# npm
npm uninstall -g openclaw
# Remove configuration and data
rm -rf ~/.openclaw
# Homebrew
brew uninstall openclaw
# Docker
docker rmi openclaw/openclaw
docker volume rm openclaw-data
OpenCode 是一个可以让你用 AI 帮写代码的工具。就像有一个超级聪明的程序员朋友,随时帮你写代码、修 bug!
Windows 用户:
Mac 用户:
Linux 用户:
curl -fsSL https://opencode.ai/install.sh | bash
Windows:
Mac:
Linux:
sudo dpkg -i opencode_*.debsudo rpm -i opencode_*.rpm打不开怎么办?
登录不了?
重要:OpenCode CLI(v1.2.24)的
--help输出里 没有skills相关子命令,因此 OpenCode 本身不负责安装/管理 OpenClaw Skills。这套内容是 OpenClaw Skill(目录:
skills/openclaw-installer/)。
你可以用 OpenCode 来:
在存放该 skill 的目录打开终端,然后运行:
# 进入 skill 目录(Windows PowerShell 示例)
cd C:\Users\24512\.openclaw\workspace\skills\openclaw-installer
# 让 OpenCode 读取并总结(示例)
opencode run "Read SKILL.md and docs/windows.md. Summarize the Windows install steps into a 10-step checklist."
OpenCode --help 中已验证存在这些运维相关命令:
opencode serve(无界面 server)opencode web(启动并打开 web)opencode session(会话管理)opencode stats(用量统计)opencode export/import(导出/导入)opencode upgrade/uninstall(升级/卸载)示例:
opencode stats
opencode session list
opencode export <sessionID>
帮助开发者了解用户如何使用 OpenClaw 和 OpenCode,改进产品!
| 信息类型 | 用途 | 是否必须 |
|---|---|---|
| 操作系统版本 | 适配不同系统 | 必须 |
| OpenClaw 版本 | 排查问题 | 必须 |
| OpenCode 版本 | 排查问题 | 必须 |
| Node.js 版本 | 排查兼容问题 | 必须 |
| 安装方式 | 优化安装流程 | 推荐 |
| 错误日志 | 修复 bug | 必须 |
| 使用时长 | 了解用户习惯 | 可选 |
| 功能偏好 | 新功能规划 | 可选 |
| 反馈建议 | 产品改进 | 可选 |
创建 scripts/collect-user-info.sh:
#!/bin/bash
# 用户信息收集脚本
echo "=== OpenClaw 用户信息收集 ==="
# 系统信息
echo "操作系统: $(uname -a)"
echo "系统版本: $(cat /etc/os-release 2>/dev/null | grep PRETTY_NAME | cut -d= -f2)"
# OpenClaw 版本
if command -v openclaw &> /dev/null; then
echo "OpenClaw版本: $(openclaw --version)"
echo "OpenClaw状态: $(openclaw status --json 2>/dev/null)"
fi
# OpenCode 版本
if command -v opencode &> /dev/null; then
echo "OpenCode版本: $(opencode --version)"
fi
# Node.js 版本
echo "Node.js版本: $(node --version)"
echo "npm版本: $(npm --version)"
# Docker 版本
if command -v docker &> /dev/null; then
echo "Docker版本: $(docker --version)"
fi
# 错误日志
echo "=== 最近错误日志 ==="
tail -50 ~/.openclaw/logs/*.log 2>/dev/null
# 保存到文件
DATE=$(date +%Y%m%d-%H%M%S)
FILENAME="user-info-${DATE}.txt"
{
echo "=== 收集时间: $(date) ==="
echo "=== 系统信息 ==="
uname -a
echo "=== OpenClaw 版本 ==="
openclaw --version 2>/dev/null
echo "=== OpenCode 版本 ==="
opencode --version 2>/dev/null
echo "=== Node.js 版本 ==="
node --version
echo "=== 错误日志 ==="
tail -100 ~/.openclaw/logs/*.log 2>/dev/null
} > ~/$FILENAME
echo "信息已保存到: ~/$FILENAME"
# 一键收集所有信息
bash scripts/collect-user-info.sh
# 或者逐个执行
uname -a > user-info.txt
openclaw --version >> user-info.txt
node --version >> user-info.txt
创建 scripts/auto-report.sh:
#!/bin/bash
# 自动上报用户信息(需要配置服务器 URL)
SERVER_URL="https://your-report-server.com/api/report"
# 收集基本信息
INFO=$(cat <<EOF
{
"os": "$(uname -a)",
"openclaw_version": "$(openclaw --version 2>/dev/null)",
"opencode_version": "$(opencode --version 2>/dev/null)",
"node_version": "$(node --version)",
"timestamp": "$(date -Iseconds)"
}
EOF
)
# 上报服务器
curl -X POST "$SERVER_URL" \
-H "Content-Type: application/json" \
-d "$INFO"
echo "信息已上报"
收集后可以分析:
# 1. 检查电脑有没有 Node.js
node --version
# 2. 没有的话去下载:https://nodejs.org
# 3. 安装 OpenClaw
npm install -g openclaw
# 4. 验证安装成功
openclaw --version
# 5. 第一次设置
openclaw onboard
# 1. 去 opencode.ai 下载
# 2. 安装完成后打开
# 3. 用 GitHub 账号登录
# 4. 测试一下
!help
# 1. 复制 skill 文件夹到正确位置
cp -r openclaw-installer ~/.opencode/skills/
# 2. 在 OpenCode 里验证
!skills list
# 3. 试试看
!openclaw install help
# 1. 运行收集脚本
bash scripts/collect-user-info.sh
# 2. 查看收集了什么
cat user-info-*.txt
# 3. (可选)上报给开发者
bash scripts/auto-report.sh
MIT License - See LICENSE file for details.