openclaw.ai 上。
All three support Node 22.22.3+, 24.15+, or 25.9+. On macOS and Linux, fresh installs provision Node 26; on Windows, winget/Chocolatey/Scoop install the supported Node LTS line, and the portable fallback downloads Node 26.
快速命令
- install.sh
- install-cli.sh
- install.ps1
如果安装成功但在新的终端中找不到
openclaw,请参阅 Node.js 故障排查。install.sh
流程 (install.sh)
1
检测操作系统
支持 macOS 和 Linux(包括 WSL)。
2
Ensure Node.js 26 by default
Checks Node version and installs Node 26 if needed (Homebrew
node on macOS, NodeSource setup scripts on Linux apt/dnf/yum). On macOS, Homebrew is installed only when the installer needs it for Node or Git. Node 22.22.3+, Node 24.15+, and Node 25.9+ are supported; Node 23 is unsupported.
On Alpine/musl Linux, the installer uses apk packages instead of NodeSource and verifies the actual linked SQLite version. Current stable Alpine package streams can provide a new-enough Node with vulnerable system SQLite; when that happens, use an official node:26-alpine container or a glibc-based host instead.3
确保 Git
如果缺少 Git,会使用检测到的包管理器安装,包括 macOS 上的 Homebrew 和 Alpine 上的 apk。
4
安装 OpenClaw
npm方式(默认):全局 npm 安装git方式:克隆/更新仓库,用 pnpm 安装依赖、构建,然后在~/.local/bin/openclaw安装包装器
5
安装后任务
- 解析刚安装的
openclaw二进制文件,以便后续命令使用 - 对于未配置的安装,会在 doctor 或 gateway 探测之前启动引导。使用
--no-onboard或在没有 TTY 的情况下,它会打印稍后完成设置的命令。 - 对于已配置的安装,会尽力刷新并重启已加载的 gateway 服务,并运行 doctor。升级会在可能时更新插件;或者在支持交互提示的无头运行中打印手动命令。
- 当运行
--verify时,仅在存在配置后才会检查已安装版本并检查 gateway 健康状况。
源码检出检测
如果在 OpenClaw 检出版本中运行(package.json + pnpm-workspace.yaml),脚本会提供:
- 使用检出版本(
git),或 - 使用全局安装(
npm)
npm 并发出警告。
如果方法选择无效或 --install-method 值无效,脚本会以退出码 2 退出。
示例 (install.sh)
- 默认
- 跳过引导
- Git 安装
- GitHub main 检出
- Dry run
- 安装后验证
标志参考
标志参考
环境变量参考
环境变量参考
install-cli.sh
专为希望将所有内容都放在本地前缀
(默认
~/.openclaw)下、且不依赖系统 Node 的环境而设计。默认支持 npm 安装,
也支持在相同前缀流程下进行 git 检出安装。流程 (install-cli.sh)
1
安装本地 Node 运行时
下载一个固定版本的受支持 Node LTS tarball(该版本内嵌在脚本中并独立更新,默认
24.15.0)到 <prefix>/tools/node-v<version>,并验证 SHA-256。
Linux ARMv7 使用 Node 22.22.3,因为官方 Node 24+ ARMv7 二进制文件不可用。
在 Alpine/musl Linux 上,由于 Node 不会为固定运行时发布兼容的 tarball,会通过 apk 安装 nodejs 和 npm,然后验证 Node 以及实际链接的 SQLite 库。当前稳定版 Alpine 软件包流即使使用足够新的 Node,也可能仍然链接到存在漏洞的 SQLite;如果安全检查拒绝该软件包,请使用官方 node:24-alpine 容器或基于 glibc 的主机。2
确保 Git 可用
如果缺少 Git,会尝试通过 Linux 上的 apt/dnf/yum/apk 或 macOS 上的 Homebrew 安装。
3
在前缀下安装 OpenClaw
npm方式(默认):通过 npm 安装到前缀下,然后将包装器写入<prefix>/bin/openclawgit方式:克隆/更新一个检出目录(默认~/openclaw),并仍然将包装器写入<prefix>/bin/openclaw
4
刷新已加载的网关服务
如果已经从同一前缀加载了网关服务,脚本会运行
openclaw gateway install --force,这会激活替换后的服务,
然后尽力探测网关健康状态。示例 (install-cli.sh)
- 默认
- 自定义前缀 + 版本
- Git 安装
- 自动化 JSON 输出
- 运行引导
标志参考
标志参考
环境变量参考
环境变量参考
openclaw@main 和其他 GitHub 源规格并不是 npm 安装可用的 --version 目标。请改用 --install-method git --version main。install.ps1
流程(install.ps1)
1
确保 PowerShell + Windows 环境
需要 PowerShell 5+。
2
Ensure a supported Node.js runtime
If missing, attempts install via winget, then Chocolatey, then Scoop. If no package manager is available, the script downloads the official Node.js 26 Windows zip into
%LOCALAPPDATA%\OpenClaw\deps\portable-node and adds it to the current process and user PATH. Node 22.22.3+, Node 24.15+, and Node 25.9+ are supported; Node 23 is unsupported.3
安装 OpenClaw
npm方法(默认):使用所选的-Tag进行全局 npm 安装,并从可写的安装临时目录启动,因此即使在受保护的文件夹(如C:\)中打开的 shell 也能正常工作git方法:克隆/更新仓库,使用 pnpm 安装/构建,并在%USERPROFILE%\.local\bin\openclaw.cmd安装包装器。如果缺少 Git,脚本会在%LOCALAPPDATA%\OpenClaw\deps\portable-git下引导安装用户本地 MinGit,并将其添加到当前进程和用户 PATH。
4
安装后任务
- 在可能的情况下,将所需的 bin 目录添加到用户 PATH
- 最佳努力刷新已加载的 gateway 服务(
openclaw gateway install --force,然后重启) - 在升级和 git 安装时运行
openclaw doctor --non-interactive(最佳努力)
5
处理失败
iwr ... | iex 和 scriptblock 安装会报告终止性错误,但不会关闭当前 PowerShell 会话。直接通过 powershell -File / pwsh -File 安装时仍会以非零状态退出,便于自动化处理。示例(install.ps1)
- 默认
- Git 安装
- GitHub main 检出
- 自定义 git 目录
- 试运行
标志参考
标志参考
环境变量参考
环境变量参考
如果使用了
-InstallMethod git 且缺少 Git,脚本会先尝试引导安装用户本地 MinGit,然后再打印 Git for Windows 链接。CI 和自动化
使用非交互标志/环境变量以获得可预测的运行结果。- install.sh(非交互 npm)
- install.sh(非交互 git)
- install-cli.sh(JSON)
- install.ps1(跳过引导)
故障排查
为什么需要 Git?
为什么需要 Git?
git 安装方式需要 Git。对于 npm 安装,仍会检查/安装 Git,以避免依赖使用 git URL 时出现 spawn git ENOENT 失败。为什么 npm 在 Linux 上会遇到 EACCES?
为什么 npm 在 Linux 上会遇到 EACCES?
某些 Linux 环境会将 npm 的全局前缀指向由 root 拥有的路径。
install.sh 可以将前缀切换为 ~/.npm-global,并把 PATH 导出项追加到 shell 的 rc 文件中(如果这些文件存在)。Windows: "npm error spawn git / ENOENT"
Windows: "npm error spawn git / ENOENT"
重新运行安装程序,让它引导安装用户本地 MinGit,或者安装 Git for Windows 后重新打开 PowerShell。
Windows: "openclaw is not recognized"
Windows: "openclaw is not recognized"
运行
npm config get prefix,并将该目录添加到你的用户 PATH(在 Windows 上不需要 \bin 后缀),然后重新打开 PowerShell。Windows: 如何获取详细的安装程序输出
Windows: 如何获取详细的安装程序输出
install.ps1 不提供 -Verbose 开关。
使用 PowerShell 跟踪来进行脚本级诊断:安装后找不到 openclaw
安装后找不到 openclaw
通常是 PATH 问题。请参见 Node.js 故障排查。