💡 除非有特殊原因,否则请使用安装器。它会自动设置 CLI 并运行新手引导,是最简单的安装方式。
一、快速安装(推荐)
在慈云数据服务器上通过 SSH 连接后,执行以下命令即可一键安装:
Linux / macOS
curl -fsSL https://openclaw.ai/install.sh | bash
Windows(PowerShell)
iwr -useb https://openclaw.ai/install.ps1 | iex
下一步(如果你跳过了新手引导)
openclaw onboard --install-daemon
二、系统要求
- Node.js ≥ 22(推荐使用 LTS 版本)
- macOS、Linux 或通过 WSL2 的 Windows
pnpm 仅在从源代码构建时需要
💡 慈云数据的云服务器支持 Windows 和 Linux 双系统,推荐选择 Ubuntu 22.04 / CentOS 7+ 系统镜像,开通后通过 SSH 连接即可开始安装。
三、选择安装路径
方式 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.js:
npm install -g openclaw@latest
如果你全局安装了 libvips(macOS 上通过 Homebrew 安装很常见)且 sharp 安装失败,请强制使用预构建二进制文件:
SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install -g openclaw@latest
⚠️ 如果你看到 sharp: Please add node-gyp to your dependencies,要么安装构建工具(macOS:Xcode CLT + npm install -g node-gyp),要么使用上面的 SHARP_IGNORE_GLOBAL_LIBVIPS=1 变通方法来跳过原生构建。
使用 pnpm 安装:
pnpm add -g openclaw@latest
pnpm approve-builds -g
pnpm add -g openclaw@latest
💡 pnpm 需要显式批准带有构建脚本的包。在首次安装显示 "Ignored build scripts" 警告后,运行 pnpm approve-builds -g 并选择列出的包,然后重新运行安装以执行 postinstall 脚本。
安装完成后运行新手引导:
openclaw onboard --install-daemon
方式 3:从源代码构建(贡献者/开发)
git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install
pnpm ui:build
pnpm build
openclaw onboard --install-daemon
💡 如果你还没有全局安装,请通过 pnpm openclaw ... 运行仓库命令。
方式 4:其他安装选项
- Docker 容器部署
- Nix 包管理器
- Ansible 自动化部署
- Bun 运行时(仅 CLI)
四、安装后操作
安装完成后,依次执行以下命令确认一切正常:
openclaw onboard --install-daemon
openclaw doctor
openclaw status
openclaw health
openclaw dashboard
五、安装方式:npm vs git
安装器支持两种方式:
npm(默认):通过 npm install -g openclaw@latest 安装
git:从 GitHub 克隆/构建并从源代码 checkout 运行
六、CLI 标志
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --install-method npm
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --install-method git
常用标志一览:
--install-method npm|git — 选择安装方式
--git-dir — 指定 git 目录(默认:~/openclaw)
--no-git-update — 使用现有 checkout 时跳过 git pull
--no-prompt — 禁用提示(CI/自动化中必需)
--dry-run — 打印将要执行的操作,不做任何更改
--no-onboard — 跳过新手引导
七、环境变量
等效的环境变量(对自动化和 CI/CD 有用):
| 环境变量 |
可选值 |
说明 |
OPENCLAW_INSTALL_METHOD |
git | npm |
安装方式 |
OPENCLAW_GIT_DIR |
路径 |
git 克隆目录 |
OPENCLAW_GIT_UPDATE |
0 | 1 |
是否执行 git pull |
OPENCLAW_NO_PROMPT |
1 |
禁用交互提示 |
OPENCLAW_DRY_RUN |
1 |
仅打印不执行 |
OPENCLAW_NO_ONBOARD |
1 |
跳过新手引导 |
SHARP_IGNORE_GLOBAL_LIBVIPS |
0 | 1(默认 1) |
避免 sharp 针对系统 libvips 构建 |
八、故障排除:找不到 openclaw(PATH)
如果安装后执行 openclaw 提示命令未找到,先运行以下诊断命令:
node -v
npm prefix -g
echo "$PATH"
如果 $(npm prefix -g)/bin(macOS/Linux)或 $(npm prefix -g)(Windows)不在 PATH 输出中,你的 shell 无法找到全局 npm 二进制文件。
修复方法
将以下内容添加到你的 shell 启动文件(zsh:~/.zshrc,bash:~/.bashrc):
export PATH="$(npm prefix -g)/bin:$PATH"
⚠️ Windows 用户请将 npm prefix -g 的输出手动添加到系统环境变量 PATH 中。
然后打开新终端,或执行以下命令刷新:
rehash
hash -r
✅ 完成以上步骤后,你的 OpenClaw AI 系统就已经在慈云数据服务器上成功部署了。运行 openclaw dashboard 打开管理面板,开始使用吧!