源码安装:

(一)前置依赖安装

OpenClaw 2026依赖Node.js ≥22.x与pnpm包管理器,执行以下命令一键配置:

# 安装nvm(Node版本管理器)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
source ~/.bashrc  # Linux
source ~/.zshrc   # macOS

# 安装Node.js 22
nvm install 22
nvm use 22
nvm alias default 22

# 安装pnpm
npm install -g pnpm
pnpm config set registry https://registry.npmmirror.com/

# 验证版本
node -v
pnpm -v
git --version

(二)拉取源码与安装依赖

# 克隆2026稳定版源码
git clone https://gitee.com/OpenClaw-CN/openclaw-cn.git
cd openclaw-cn
git checkout v2026.2.2-cn

# 安装依赖
pnpm install

# 构建前端与核心服务
pnpm ui:build
pnpm build

(三)初始化配置与模型对接

# 启动交互式配置向导
pnpm openclaw onboard --install-daemon

按提示选择:

  1. 同意安全条款
  2. 快速配置(QuickStart)
  3. 模型厂商选择阿里云百炼(国内稳定)
  4. 输入百炼 API Key
  5. 消息通道暂时跳过(后续配iMessage)
  6. 完成后自动打开控制台:http://127.0.0.1:18789

下次启动命令 

重启:pnpm openclaw gateway restart

开启:pnpm openclaw gateway start

停止:pnpm openclaw gateway start

官方推荐安装

除非有特殊原因,否则请使用安装器。它会设置 CLI 并运行新手引导。

快速安装(推荐)

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

Windows(PowerShell):

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

下一步(如果你跳过了新手引导):

openclaw onboard --install-daemon

系统要求

  • Node >=22
  • macOS、Linux 或通过 WSL2 的 Windows
  • pnpm 仅在从源代码构建时需要

选择安装路径

1)安装器脚本(推荐)通过 npm 全局安装 openclaw 并运行新手引导。

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

安装器标志:

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

详情:安装器内部原理。非交互式(跳过新手引导):

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

2)全局安装(手动)如果你已经有 Node:

npm install -g openclaw@latest

如果你全局安装了 libvips(macOS 上通过 Homebrew 安装很常见)且 sharp 安装失败,请强制使用预构建二进制文件:

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),要么使用上面的 SHARP_IGNORE_GLOBAL_LIBVIPS=1 变通方法来跳过原生构建。或使用 pnpm:

pnpm add -g openclaw@latest
pnpm approve-builds -g                # 批准 openclaw、node-llama-cpp、sharp 等
pnpm add -g openclaw@latest           # 重新运行以执行 postinstall 脚本

pnpm 需要显式批准带有构建脚本的包。在首次安装显示”Ignored build scripts”警告后,运行 pnpm approve-builds -g 并选择列出的包,然后重新运行安装以执行 postinstall 脚本。然后:

openclaw onboard --install-daemon
Logo

小龙虾开发者社区是 CSDN 旗下专注 OpenClaw 生态的官方阵地,聚焦技能开发、插件实践与部署教程,为开发者提供可直接落地的方案、工具与交流平台,助力高效构建与落地 AI 应用

更多推荐