3.1 安装指南

除非有特殊原因,否则使用安装器。它会设置 CLI 并运行引导。

快速安装(推荐)

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

Windows (PowerShell):

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

下一步(如果跳过了引导):

openclaw onboard --install-daemon

系统要求

  • Node ≥22
  • macOS、Linux 或 Windows(通过 WSL2)
  • pnpm 仅在从源码构建时需要

选择安装方式

1) 安装器脚本(推荐)

通过 npm 全局安装 openclaw 并运行引导。

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

安装器标志:

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

详情:安装器内部

非交互式(跳过引导):

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

2) 全局安装(手动)

如果你已经有 Node:

npm install -g openclaw@latest

如果你全局安装了 libvips(macOS 通过 Homebrew 常见)且 sharp 安装失败,强制使用预构建二进制文件:

SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install -g openclaw@latest

或:

pnpm add -g openclaw@latest

然后:

openclaw onboard --install-daemon

3) 从源码(贡献者/开发)

git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install
pnpm ui:build # 首次运行时自动安装 UI 依赖
pnpm build
openclaw onboard --install-daemon

提示:如果还没有全局安装,通过 pnpm openclaw ... 运行仓库命令。

4) 其他安装选项

安装后

  • 运行引导:openclaw onboard --install-daemon
  • 快速检查:openclaw doctor
  • 检查 gateway 健康:openclaw status + openclaw health
  • 打开 dashboard:openclaw dashboard

CLI 标志

# 显式 npm
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --install-method npm

# 从 GitHub 安装(源码检出)
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --install-method git

常用标志:

  • --install-method npm|git
  • --git-dir <path>(默认:~/openclaw)
  • --no-git-update(使用现有检出时跳过 git pull)
  • --no-prompt(禁用提示;CI/自动化中需要)
  • --dry-run(打印将要发生的事情;不做更改)
  • --no-onboard(跳过引导)

环境变量

等效的环境变量(用于自动化):

  • OPENCLAW_INSTALL_METHOD=git|npm
  • OPENCLAW_GIT_DIR=...
  • OPENCLAW_GIT_UPDATE=0|1
  • OPENCLAW_NO_PROMPT=1
  • OPENCLAW_DRY_RUN=1
  • OPENCLAW_NO_ONBOARD=1
  • SHARP_IGNORE_GLOBAL_LIBVIPS=0|1(默认:1;避免 sharp 构建对系统 libvips)

故障排除:openclaw not found (PATH)

快速诊断:

node -v
npm -v
npm prefix -g
echo "$PATH"

如果 $(npm prefix -g)/bin(macOS/Linux)或 $(npm prefix -g)(Windows)不在 echo "$PATH" 中,你的 shell 找不到全局 npm 二进制文件(包括 openclaw)。

修复:添加到你的 shell 启动文件(zsh: ~/.zshrc,bash: ~/.bashrc):

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

然后打开新终端(或在 zsh 中 rehash / bash 中 hash -r)。

更新 / 卸载