安装程序内部机制
安装程序内部机制
OpenClaw 提供三个安装脚本,从 openclaw.ai 提供服务。
| 脚本 | 平台 | 功能 |
|---|---|---|
install.sh | macOS / Linux / WSL | 按需安装 Node,通过 npm(默认)或 git 安装 OpenClaw,并可运行入门向导。 |
install-cli.sh | macOS / Linux / WSL | 将 Node + OpenClaw 安装到本地前缀(~/.openclaw)。无需 root 权限。 |
install.ps1 | Windows (PowerShell) | 按需安装 Node,通过 npm(默认)或 git 安装 OpenClaw,并可运行入门向导。 |
快速命令
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash -s -- --help
如果安装成功但在新终端中找不到 openclaw,请参阅 Node.js 故障排除。
install.sh
推荐用于 macOS/Linux/WSL 上的大多数交互式安装。
流程(install.sh)
检测操作系统
支持 macOS 和 Linux(包括 WSL)。如果检测到 macOS,会在缺少时安装 Homebrew。
确保 Node.js 22+
检查 Node 版本,按需安装 Node 22(macOS 上使用 Homebrew,Linux apt/dnf/yum 上使用 NodeSource 设置脚本)。
确保 Git
缺少时安装 Git。
安装 OpenClaw
npm方法(默认):全局 npm 安装git方法:克隆/更新仓库,用 pnpm 安装依赖,构建,然后在~/.local/bin/openclaw安装包装器
安装后任务
- 在升级和 git 安装时运行
openclaw doctor --non-interactive(尽力而为) - 在适当时尝试入门(有 TTY 可用、未禁用入门、且 bootstrap/config 检查通过)
- 默认设置
SHARP_IGNORE_GLOBAL_LIBVIPS=1
源码检出检测
如果在 OpenClaw 检出目录内运行(存在 package.json + pnpm-workspace.yaml),脚本会提供:
- 使用检出(
git),或 - 使用全局安装(
npm)
如果没有 TTY 可用且未设置安装方法,默认使用 npm 并警告。
如果方法选择无效或 --install-method 值无效,脚本以退出码 2 退出。
示例(install.sh)
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash
install-cli.sh
专为希望将所有内容置于本地前缀(默认 ~/.openclaw)且无系统 Node 依赖的环境设计。
流程(install-cli.sh)
安装本地 Node 运行时
下载 Node tarball(默认 22.22.0)到 <prefix>/tools/node-v<version> 并验证 SHA-256。
确保 Git
如果缺少 Git,尝试通过 Linux 上的 apt/dnf/yum 或 macOS 上的 Homebrew 安装。
在前缀下安装 OpenClaw
使用 --prefix <prefix> 通过 npm 安装,然后写入包装器到 <prefix>/bin/openclaw。
示例(install-cli.sh)
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install-cli.sh | bash
install.ps1
流程(install.ps1)
确保 PowerShell + Windows 环境
需要 PowerShell 5+。
确保 Node.js 22+
如果缺少,尝试通过 winget 安装,然后 Chocolatey,然后 Scoop。
安装 OpenClaw
npm方法(默认):使用选定的-Tag全局 npm 安装git方法:克隆/更新仓库,用 pnpm 安装/构建,并在%USERPROFILE%\.local\bin\openclaw.cmd安装包装器
安装后任务
可能时将需要的 bin 目录添加到用户 PATH,然后在升级和 git 安装时运行 openclaw doctor --non-interactive(尽力而为)。
示例(install.ps1)
iwr -useb https://openclaw.ai/install.ps1 | iex
如果使用 -InstallMethod git 且缺少 Git,脚本会退出并打印 Git for Windows 链接。
CI 和自动化
使用非交互式标志/环境变量进行可预测的运行。
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash -s -- --no-prompt --no-onboard