安装器内部原理

OpenClaw 提供三个安装脚本,从 openclaw.ai 提供?

脚本平台功能
install.shmacOS / Linux / WSL如需要安?Node,通过 npm(默认)?git 安装 OpenClaw,并可以运行入门配置?
install-cli.shmacOS / Linux / WSL?Node + OpenClaw 安装到本地前缀(~/.openclaw)。不需?root?
install.ps1Windows (PowerShell)如需要安?Node,通过 npm(默认)?git 安装 OpenClaw,并可以运行入门配置?

快速命?

```bash curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash ```
```bash
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash -s -- --help
```
```bash curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install-cli.sh | bash ```
```bash
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install-cli.sh | bash -s -- --help
```
```powershell iwr -useb https://openclaw.ai/install.ps1 | iex ```
```powershell
& ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -Tag beta -NoOnboard -DryRun
```
如果安装成功但在新终端中找不?`openclaw`,请参见 [Node.js 故障排除](/zh/docs/install/node#troubleshooting)?

install.sh

推荐用于 macOS/Linux/WSL 上的大多数交互式安装?

流程(install.sh?

检?Node 版本,如需要则安装 Node 22(macOS 上使?Homebrew,Linux apt/dnf/yum 上使?NodeSource 设置脚本)? 如缺失则安装 Git? - `npm` 方法(默认):全局 npm 安装 - `git` 方法:克?更新仓库,使?pnpm 安装依赖并构建,然后?`~/.local/bin/openclaw` 安装包装?

源代?checkout 检?

如果?OpenClaw checkout(package.json + pnpm-workspace.yaml)内运行,脚本会提供?

  • 使用 checkout(git),?
  • 使用全局安装(npm?

如果没有可用?TTY 且未设置安装方法,它默认?npm 并发出警告?

脚本以代?2 退出,表示无效的方法选择或无效的 --install-method 值?

示例(install.sh?

```bash curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash ``` ```bash curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash -s -- --no-onboard ``` ```bash curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash -s -- --install-method git ``` ```bash curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash -s -- --dry-run ```
标志描述
`—install-method npmgit`
--npmnpm 方法的快捷方?
--gitgit 方法的快捷方式。别名:--github
`—version <versiondist-tag>`
--beta如果可用使用 beta dist-tag,否则回退?latest
--git-dir <path>Checkout 目录(默认:~/openclaw)。别名:--dir
--no-git-update跳过现有 checkout ?git pull
--no-prompt禁用提示
--no-onboard跳过入门配置
--onboard启用入门配置
--dry-run打印操作而不应用更改
--verbose启用调试输出(set -x,npm notice 级别日志?
--help显示用法(-h?

<Accordion title=“环境变量参?>

变量描述
`OPENCLAW_INSTALL_METHOD=gitnpm`
`OPENCLAW_VERSION=latestnext
`OPENCLAW_BETA=01`
OPENCLAW_GIT_DIR=<path>Checkout 目录
`OPENCLAW_GIT_UPDATE=01`
OPENCLAW_NO_PROMPT=1禁用提示
OPENCLAW_NO_ONBOARD=1跳过入门配置
OPENCLAW_DRY_RUN=1模拟运行模式
OPENCLAW_VERBOSE=1调试模式
`OPENCLAW_NPM_LOGLEVEL=errorwarn
`SHARP_IGNORE_GLOBAL_LIBVIPS=01`

install-cli.sh

设计用于你希望所有内容都在本地前缀(默?`~/.openclaw`)下且无系统 Node 依赖的环境?

流程(install-cli.sh?

如果 Git 缺失,尝试通过 Linux 上的 apt/dnf/yum ?macOS 上的 Homebrew 安装? 使用 npm 通过 `--prefix ` 安装,然后写入包装器?`/bin/openclaw`?

示例(install-cli.sh?

```bash curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install-cli.sh | bash ``` ```bash curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install-cli.sh | bash -s -- --prefix /opt/openclaw --version latest ``` ```bash curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install-cli.sh | bash -s -- --json --prefix /opt/openclaw ``` ```bash curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install-cli.sh | bash -s -- --onboard ```
标志描述
--prefix <path>安装前缀(默认:~/.openclaw?
--version <ver>OpenClaw 版本?dist-tag(默认:latest?
--node-version <ver>Node 版本(默认:22.22.0?
--json发出 NDJSON 事件
--onboard安装后运?openclaw onboard
--no-onboard跳过入门配置(默认)
--set-npm-prefix?Linux 上,如果当前前缀不可写,强制 npm 前缀?~/.npm-global
--help显示用法(-h?

<Accordion title=“环境变量参?>

变量描述
OPENCLAW_PREFIX=<path>安装前缀
OPENCLAW_VERSION=<ver>OpenClaw 版本?dist-tag
OPENCLAW_NODE_VERSION=<ver>Node 版本
OPENCLAW_NO_ONBOARD=1跳过入门配置
`OPENCLAW_NPM_LOGLEVEL=errorwarn
OPENCLAW_GIT_DIR=<path>旧版清理查找路径(当移除旧的 Peekaboo 子模?checkout 时使用)
`SHARP_IGNORE_GLOBAL_LIBVIPS=01`

install.ps1

流程(install.ps1?

需?PowerShell 5+? 如缺失,尝试通过 winget,然?Chocolatey,然?Scoop 安装? - `npm` 方法(默认):使用选定?`-Tag` 进行全局 npm 安装 - `git` 方法:克?更新仓库,使?pnpm 安装/构建,并?`%USERPROFILE%\.local\bin\openclaw.cmd` 安装包装?

示例(install.ps1?

```powershell iwr -useb https://openclaw.ai/install.ps1 | iex ``` ```powershell & ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -InstallMethod git ``` ```powershell & ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -InstallMethod git -GitDir "C:\openclaw" ``` ```powershell & ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -DryRun ``` ```powershell # install.ps1 还没有专门的 -Verbose 标志? Set-PSDebug -Trace 1 & ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -NoOnboard Set-PSDebug -Trace 0 ```
标志描述
`-InstallMethod npmgit`
-Tag <tag>npm dist-tag(默认:latest?
-GitDir <path>Checkout 目录(默认:%USERPROFILE%\openclaw
-NoOnboard跳过入门配置
-NoGitUpdate跳过 git pull
-DryRun仅打印操?

<Accordion title=“环境变量参?>

变量描述
`OPENCLAW_INSTALL_METHOD=gitnpm`
OPENCLAW_GIT_DIR=<path>Checkout 目录
OPENCLAW_NO_ONBOARD=1跳过入门配置
OPENCLAW_GIT_UPDATE=0禁用 git pull
OPENCLAW_DRY_RUN=1模拟运行模式
如果使用 `-InstallMethod git` ?Git 缺失,脚本会退出并打印 Git for Windows 链接?

CI 和自动化

使用非交互式标志/环境变量以获得可预测的运行?

```bash OPENCLAW_INSTALL_METHOD=git OPENCLAW_NO_PROMPT=1 \ curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash ``` ```powershell & ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -NoOnboard ```

故障排除

<Accordion title=“为什?npm ?Linux 上遇?EACCES?> 某些 Linux 设置?npm 全局前缀指向 root 拥有的路径。install.sh 可以将前缀切换?~/.npm-global 并将 PATH 导出追加?shell rc 文件(当这些文件存在时)?

脚本默认设置 `SHARP_IGNORE_GLOBAL_LIBVIPS=1` 以避?sharp 针对系统 libvips 构建。要覆盖?
```bash
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`,追?`\bin`,将该目录添加到用户 PATH,然后重新打开 PowerShell? `install.ps1` 当前不公开 `-Verbose` 开关? 使用 PowerShell 跟踪进行脚本级诊断:
```powershell
Set-PSDebug -Trace 1
& ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -NoOnboard
Set-PSDebug -Trace 0
```
通常?PATH 问题。请参见 [Node.js 故障排除](/zh/docs/install/node#troubleshooting)?