> ## Documentation Index
> Fetch the complete documentation index at: https://openclaw.veiseule.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 安装

# 安装

已经完成了[快速开始](/start/getting-started)？那你已经准备就绪 —— 本页面介绍其他安装方式、特定平台说明以及维护相关内容。

## 系统要求

* **[Node 22+](/install/node)**（如果未安装，[安装器脚本](#install-methods)会自动安装）
* macOS、Linux，或 Windows
* 仅在从源代码构建时需要 `pnpm`

<Note>
  在 Windows 上，我们强烈建议在 [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) 下运行 OpenClaw。
</Note>

## 安装方式

<Tip>
  **安装器脚本**是推荐的 OpenClaw 安装方式。它会在一步中完成 Node 检测、安装和新手引导。
</Tip>

<AccordionGroup>
  <Accordion title="安装器脚本" icon="rocket" defaultOpen>
    下载 CLI，通过 npm 全局安装，并启动新手引导向导。

    <Tabs>
      <Tab title="macOS / Linux / WSL2">
        ```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
        curl -fsSL https://openclaw.ai/install.sh | bash
        ```
      </Tab>

      <Tab title="Windows (PowerShell)">
        ```powershell theme={"theme":{"light":"min-light","dark":"min-dark"}}
        iwr -useb https://openclaw.ai/install.ps1 | iex
        ```
      </Tab>
    </Tabs>

    就这么简单 —— 脚本会自动处理 Node 检测、安装和新手引导。

    若要跳过新手引导，仅安装二进制文件：

    <Tabs>
      <Tab title="macOS / Linux / WSL2">
        ```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
        curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard
        ```
      </Tab>

      <Tab title="Windows (PowerShell)">
        ```powershell theme={"theme":{"light":"min-light","dark":"min-dark"}}
        & ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -NoOnboard
        ```
      </Tab>
    </Tabs>

    有关所有标志、环境变量和 CI/自动化选项，请参阅[安装器内部原理](/install/installer)。
  </Accordion>

  <Accordion title="npm / pnpm" icon="package">
    如果你已经安装了 Node 22+，并希望自行管理安装：

    <Tabs>
      <Tab title="npm">
        ```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
        npm install -g openclaw@latest
        openclaw onboard --install-daemon
        ```

        <Accordion title="sharp 构建错误？">
          如果你全局安装了 libvips（在 macOS 上通过 Homebrew 安装很常见）且 `sharp` 安装失败，请强制使用预构建二进制文件：

          ```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
          SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install -g openclaw@latest
          ```

          如果你看到 `sharp: Please add node-gyp to your dependencies`，请安装构建工具（macOS：Xcode CLT + `npm install -g node-gyp`），或使用上面的环境变量。
        </Accordion>
      </Tab>

      <Tab title="pnpm">
        ```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
        pnpm add -g openclaw@latest
        pnpm approve-builds -g        # 批准 openclaw、node-llama-cpp、sharp 等
        openclaw onboard --install-daemon
        ```

        <Note>
          pnpm 需要对带有构建脚本的包进行显式批准。首次安装出现 "Ignored build scripts" 警告后，运行 `pnpm approve-builds -g` 并选择列出的包。
        </Note>
      </Tab>
    </Tabs>
  </Accordion>

  <Accordion title="从源代码" icon="github">
    适用于贡献者或希望从本地仓库运行的用户。

    <Steps>
      <Step title="克隆并构建">
        克隆 [OpenClaw 仓库](https://github.com/openclaw/openclaw) 并构建：

        ```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
        git clone https://github.com/openclaw/openclaw.git
        cd openclaw
        pnpm install
        pnpm ui:build
        pnpm build
        ```
      </Step>

      <Step title="链接 CLI">
        使 `openclaw` 命令在全局可用：

        ```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
        pnpm link --global
        ```

        或者跳过 link，在仓库目录中使用 `pnpm openclaw ...` 运行命令。
      </Step>

      <Step title="运行新手引导">
        ```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
        openclaw onboard --install-daemon
        ```
      </Step>
    </Steps>

    有关更深入的开发工作流，请参阅 [Setup](/start/setup)。
  </Accordion>
</AccordionGroup>

## 其他安装方式

<CardGroup cols={2}>
  <Card title="Docker" href="/install/docker" icon="container">
    容器化或无头部署。
  </Card>

  <Card title="Podman" href="/install/podman" icon="container">
    无 root 容器：先运行 `setup-podman.sh`，然后运行启动脚本。
  </Card>

  <Card title="Nix" href="/install/nix" icon="snowflake">
    通过 Nix 进行声明式安装。
  </Card>

  <Card title="Ansible" href="/install/ansible" icon="server">
    自动化批量部署。
  </Card>

  <Card title="Bun" href="/install/bun" icon="zap">
    通过 Bun 运行时仅使用 CLI。
  </Card>
</CardGroup>

## 安装后

验证是否一切正常：

```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
openclaw doctor         # 检查配置问题
openclaw status         # gateway 状态
openclaw dashboard      # 打开浏览器 UI
```

如需自定义运行路径，可使用：

* `OPENCLAW_HOME` 指定基于主目录的内部路径
* `OPENCLAW_STATE_DIR` 指定可变状态存储位置
* `OPENCLAW_CONFIG_PATH` 指定配置文件路径

有关优先级和完整说明，请参阅[环境变量](/help/environment)。

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

<Accordion title="PATH 诊断与修复">
  快速诊断：

  ```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
  node -v
  npm -v
  npm prefix -g
  echo "$PATH"
  ```

  如果 `$(npm prefix -g)/bin`（macOS/Linux）或 `$(npm prefix -g)`（Windows）**不**在你的 `$PATH` 中，shell 将无法找到全局 npm 二进制文件（包括 `openclaw`）。

  修复 —— 将其添加到你的 shell 启动文件（`~/.zshrc` 或 `~/.bashrc`）：

  ```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
  export PATH="$(npm prefix -g)/bin:$PATH"
  ```

  在 Windows 上，将 `npm prefix -g` 的输出添加到 PATH。

  然后打开一个新的终端（或在 zsh 中运行 `rehash` / 在 bash 中运行 `hash -r`）。
</Accordion>

## 更新 / 卸载

<CardGroup cols={3}>
  <Card title="更新" href="/install/updating" icon="refresh-cw">
    保持 OpenClaw 为最新版本。
  </Card>

  <Card title="迁移" href="/install/migrating" icon="arrow-right">
    迁移到新机器。
  </Card>

  <Card title="卸载" href="/install/uninstall" icon="trash-2">
    完全移除 OpenClaw。
  </Card>
</CardGroup>
