# 安装

> 安装 OpenClaw — 安装程序脚本、npm/pnpm/bun、从源码安装、Docker 等方式

- 网址：https://funcoding.ai/agents/openclaw/install/
- 来源：OpenClaw 官方文档原文（中文），MIT 许可，同步于 2026-10-11
- 官方原文：https://docs.openclaw.ai/zh-CN/install

---
## 系统要求

- **Node 22.22.3+、24.15+ 或 25.9+** - Node 24 是默认目标版本；安装脚本会自动处理。
- **macOS、Linux 或 Windows** - Windows 用户可以从原生 Windows Hub 应用、PowerShell CLI 安装程序或 WSL2 Gateway 网关开始。请参阅 [Windows](https://funcoding.ai/agents/openclaw/platforms/windows/)。
- 仅在从源代码构建时才需要 `pnpm`。

## 推荐：安装脚本

这是最快的安装方式。它会检测你的操作系统，在需要时安装 Node，安装 OpenClaw，并启动新手引导。

<div class="callout callout-note">

Windows 桌面用户也可以安装原生 [Windows Hub](https://funcoding.ai/agents/openclaw/platforms/windows/#recommended-windows-hub) 配套应用，其中包含设置、托盘状态、聊天、节点模式和本地 MCP 模式。

</div>

**macOS / Linux / WSL2**

```bash
curl -fsSL https://openclaw.ai/install.sh | bash
```

**Windows (PowerShell)**

```powershell
iwr -useb https://openclaw.ai/install.ps1 | iex
```

若要安装但不运行新手引导：

**macOS / Linux / WSL2**

```bash
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard
```

**Windows (PowerShell)**

```powershell
& ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -NoOnboard
```

有关所有标志以及 CI/自动化选项，请参阅[安装程序内部机制](https://funcoding.ai/agents/openclaw/install/installer/)。

## 其他安装方式

### 本地前缀安装程序（`install-cli.sh`）

如果你希望将 OpenClaw 和 Node 保存在本地前缀（例如
`~/.openclaw`）下，而不依赖系统级 Node 安装，请使用此方式：

```bash
curl -fsSL https://openclaw.ai/install-cli.sh | bash
```

默认支持 npm 安装，也支持在同一前缀流程下进行 git 检出安装。完整参考：[安装程序内部机制](https://funcoding.ai/agents/openclaw/install/installer/#install-clish)。

已经安装？可使用 `openclaw update --channel dev` 和 `openclaw update --channel stable` 在软件包安装与 git 安装之间切换。请参阅
[更新](https://funcoding.ai/agents/openclaw/install/updating/#switch-between-npm-and-git-installs)。

### npm、pnpm 或 bun

如果你已经自行管理 Node：

**npm**

```bash
npm install -g openclaw@latest
openclaw onboard --install-daemon
```

<div class="callout callout-note">

托管安装程序会为 OpenClaw 软件包安装清除 npm 的新鲜度过滤条件，例如 `min-release-age`。
如果你使用 npm 手动安装，仍会应用你自己的 npm 策略。

</div>

**pnpm**

```bash
pnpm add -g openclaw@latest
pnpm approve-builds -g
openclaw onboard --install-daemon
```

<div class="callout callout-note">

pnpm 要求显式批准带有构建脚本的软件包。首次安装后请运行 `pnpm approve-builds -g`。

</div>

**bun**

```bash
bun add -g openclaw@latest
openclaw onboard --install-daemon
```

<div class="callout callout-note">

Bun 可以安装全局软件包，但生成的 `openclaw` 可执行文件需要受支持的 Node 运行时，因为 OpenClaw 状态使用 `node:sqlite`。

</div>

### 从源代码安装

适用于贡献者或希望从本地检出运行的任何人：

```bash
git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install && pnpm build && pnpm ui:build
pnpm link --global
openclaw onboard --install-daemon
```

也可以跳过链接，直接在仓库内使用 `pnpm openclaw ...`。有关完整的开发工作流，请参阅[设置](https://funcoding.ai/agents/openclaw/start/setup/)。

### 从 GitHub main 检出安装

```bash
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash -s -- --install-method git --version main
```

### 容器和软件包管理器

- [Docker](https://funcoding.ai/agents/openclaw/install/docker/)：容器化或无头部署。
- [Podman](https://funcoding.ai/agents/openclaw/install/podman/)：Docker 的无 root 容器替代方案。
- [Nix](https://funcoding.ai/agents/openclaw/install/nix/)：通过 Nix flake 进行声明式安装。
- [Ansible](https://funcoding.ai/agents/openclaw/install/ansible/)：自动化集群配置。
- [Bun](https://funcoding.ai/agents/openclaw/install/bun/)：可选的依赖安装程序和软件包脚本运行器。

## 验证安装

```bash
openclaw --version      # 确认 CLI 可用
openclaw doctor         # 检查配置问题
openclaw gateway status # 验证 Gateway 网关正在运行
```

如果你希望安装后进行托管启动：

- macOS：通过 `openclaw onboard --install-daemon` 或 `openclaw gateway install` 使用 LaunchAgent
- Linux/WSL2：通过相同命令使用 systemd 用户服务
- 原生 Windows：优先使用计划任务；如果任务创建被拒绝，则回退到每用户“启动”文件夹中的登录项

## 托管和部署

在云服务器或 VPS 上部署 OpenClaw。请参阅 [Linux 服务器](https://funcoding.ai/agents/openclaw/vps/)获取完整的
提供商选择器（DigitalOcean、Hetzner、Hostinger、Fly.io、GCP、Azure、Railway、
Northflank、Oracle Cloud、Raspberry Pi 等），或在
[Render](https://funcoding.ai/agents/openclaw/install/render/) 上进行声明式部署。

- [VPS](https://funcoding.ai/agents/openclaw/vps/)：选择提供商。
- [Docker VM](https://funcoding.ai/agents/openclaw/install/docker-vm-runtime/)：通用 Docker 步骤。
- [Kubernetes](https://funcoding.ai/agents/openclaw/install/kubernetes/)：K8s 部署。

## 更新、迁移或卸载

- [更新](https://funcoding.ai/agents/openclaw/install/updating/)：使 OpenClaw 保持最新。
- [迁移](https://funcoding.ai/agents/openclaw/install/migrating/)：迁移到新计算机。
- [卸载](https://funcoding.ai/agents/openclaw/install/uninstall/)：完全移除 OpenClaw。

## 故障排除：找不到 `openclaw`

这几乎总是 PATH 问题：npm 的全局二进制目录不在 shell 的 `PATH` 中。有关完整的修复方法（包括 Windows 路径），请参阅 [Node.js 故障排除](https://funcoding.ai/agents/openclaw/install/node/#troubleshooting)。

```bash
node -v           # 是否已安装 Node？
npm prefix -g     # 全局软件包位于何处？
echo "$PATH"      # 全局二进制目录是否在 PATH 中？
```
