跳转到主要内容

安装程序内部机制

OpenClaw 附带了三个安装程序脚本,由 openclaw.ai 提供。
脚本平台功能
install.shmacOS / Linux / WSL如果需要则安装 Node,通过 OpenClaw(默认)或 git 安装 npm,并且可以运行新手引导。
install-cli.shmacOS / Linux / WSL将 Node + OpenClaw 安装到本地前缀 (~/.openclaw) 中。无需 root 权限。
install.ps1Windows (PowerShell)如果需要则安装 Node,通过 OpenClaw(默认)或 git 安装 npm,并且可以运行新手引导。

快速命令

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)

1

检测操作系统

支持 macOS 和 Linux(包括 WSL)。如果检测到 macOS,若缺少 Homebrew 则会进行安装。
2

Ensure Node.js 24 by default

检查 Node 版本并在需要时安装 Node 24(macOS 上使用 Homebrew,Linux apt/dnf/yum 上使用 NodeSource 设置脚本)。为了兼容性,macOS 仍支持 Node 22 LTS,目前为 22.14+
3

确保 Git

如果缺少 Git,则安装 Git。
4

安装 OpenClaw

  • npm 方法(默认):全局 npm 安装 - git 方法:克隆/更新仓库,使用 pnpm 安装依赖, 然后构建,接着在 ~/.local/bin/openclaw 安装包装器
5

安装后任务

  • 在升级和 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)

bash curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash

故障排除

git 安装方法需要 Git。对于 npm 安装,仍然会检查/安装 Git,以避免当依赖项使用 git URL 时发生 spawn git ENOENT 失败。
一些 npm 配置将 Linux 全局前缀指向 root 拥有的路径。install.sh 可以将前缀切换到 ~/.npm-global 并将 PATH 导出追加到 shell rc 文件(当这些文件存在时)。
脚本默认设置 SHARP_IGNORE_GLOBAL_LIBVIPS=1 以避免 sharp 针对系统 libvips 进行构建。要覆盖此设置:
SHARP_IGNORE_GLOBAL_LIBVIPS=0 curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash
安装 Git for Windows,重新打开 PowerShell,然后重新运行安装程序。
运行 npm config get prefix 并将该目录添加到您的用户 PATH(在 Windows 上不需要 \bin 后缀),然后重新打开 PowerShell。
install.ps1 目前不暴露 -Verbose 开关。 使用 PowerShell 跟踪进行脚本级诊断:
Set-PSDebug -Trace 1
& ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -NoOnboard
Set-PSDebug -Trace 0
通常是 PATH 问题。请参阅 Node.js 故障排除

本页面源自 openclaw/openclaw,由 BeaversLab 翻译,遵循 MIT 协议 发布。
Last modified on March 27, 2026