OpenClaw

5分钟安装指南

TL;DR: 5分钟快速安装 OpenClaw 并启动本地 Gateway

关键要点

  • ✅ 推荐:使用安装脚本(最简单)
  • ✅ 系统:Node.js >= 22
  • ✅ 平台:macOS / Linux / Windows (WSL2)
  • ✅ 后续:运行向导配置

前置条件

系统要求

组件最低版本推荐版本
Node.js22+22+
pnpm9+9+
操作系统macOS / Linux / Windows (WSL2)macOS 12+ / Ubuntu 22+

重要提示

  • ✅ Windows 用户:强烈推荐使用 WSL2(Ubuntu 上的子系统)
  • ⚠️ Bun 存在已知问题,不推荐与 WhatsApp/Telegram 一起使用
  • ✅ 开发环境:使用 pnpm(比 npm 更快)

方法一:安装脚本(推荐)

macOS / Linux

curl -fsSL https://openclaw.ai/install.sh | bash

Windows (PowerShell)

iwr -useb https://openclaw.ai/install.ps1 | iex

安装脚本特点

  • ✅ 自动安装最新稳定版
  • ✅ 自动运行向导配置(openclaw onboard --install-daemon
  • ✅ 安装到系统路径(可通过终端全局访问)

跳过向导

curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard

方法二:手动全局安装

使用 npm

npm install -g openclaw@latest

使用 pnpm(推荐)

pnpm add -g openclaw@latest

macOS Homebrew 依赖问题

如果安装时遇到 sharp 错误(全局 libvips 冲突):

# 强制使用预构建二进制文件
SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install -g openclaw@latest

# 或安装构建工具
npm install -g node-gyp

错误信息示例

sharp: Please add node-gyp to your dependencies

解决方案:使用 SHARP_IGNORE_GLOBAL_LIBVIPS=1 环境变量


验证安装

检查版本

openclaw --version

预期输出

OpenClaw CLI vx.x.x.x

检查帮助

openclaw help

预期输出

Available commands:
  gateway          Run the OpenClaw Gateway daemon
  agent            Send a message to the agent
  message          Send a message to a channel
  channels         Channel management
  config           Configuration management
  ...

后续步骤

1. 运行向导配置(推荐)

openclaw onboard --install-daemon

向导配置包括

  • 🤖️ 模型认证(Anthropic 或 OpenAI)
  • 🔌 Gateway 设置(端口、绑定模式、令牌)
  • 📱 消息通道配置(WhatsApp、Telegram、Discord)
  • 🗂️ 工作空间初始化
  • 📦 后台服务安装(LaunchAgent / systemd)
  • ⚙️ Skills 自动安装

常见问题

Q: 安装后 openclaw: command not found

A: Node.js 全局路径未添加到环境变量

解决方案

# macOS/Linux
export PATH="$(npm prefix -g)/bin:$PATH"

# Windows
# 将 $(npm prefix -g) 添加到系统 PATH 环境变量

然后打开新终端或运行:

# 验证
which openclaw

Q: 如何查看安装位置?

A:

# 查看全局安装位置
npm list -g openclaw

# macOS/Linux 通常在
# /usr/local/lib/node_modules/openclaw
# ~/.npm-global/node_modules/openclaw

Q: WSL2 安装后命令无法找到?

A: Windows PATH 可能未包含 WSL2 的路径

解决方案

# 在 WSL2 中添加到 PATH
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc

# 重新加载配置
source ~/.bashrc

Q: 如何卸载?

A:

npm uninstall -g openclaw

# 或
pnpm remove -g openclaw

下一步文档


快速验证

# 1. 检查安装
openclaw --version

# 2. 检查健康状态
openclaw health

# 3. 打开控制台
openclaw dashboard

如果上述命令都正常工作,说明安装成功!🎉


更多信息请参考 文档导航

On this page