一、环境准备
在 Windows 环境下优先选择 WSL2(Ubuntu/Debian 镜像)进行部署,原生 CMD 容易报错。
- 启用 WSL2:在 Windows 功能中勾选'适用于 Linux 的 Windows 子系统'和'虚拟机平台',重启后安装 Ubuntu 22.04。
- 配置 WSL2:更新系统源(建议更换为阿里源),执行
sudo apt update && sudo apt upgrade -y。 - 安装 Git:执行
sudo apt install git,验证git --version。
二、Node.js 环境配置
仓库文档要求 Node.js 版本不低于 22。建议使用 nvm 管理环境并切换到最新版本。
注意:不要使用 22 以下版本,否则 pnpm install 会报错。
三、拉取源码与依赖安装
git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install
依赖安装问题处理
安装时可能遇到 node-llama-cpp 的 postinstall 脚本失败(错误码 3221225477)。该依赖仅用于本地嵌入,若使用远程嵌入(如 OpenAI)可忽略此错误。项目会回退到远程嵌入。解决方法是注释掉 package.json 中的 node-llama-cpp 依赖,重新执行 pnpm install。
构建项目
先构建 UI:
pnpm ui:build
再构建主项目:
pnpm build
若在原生 Windows 上构建提示缺少 bash,可在项目的 /script 目录下创建 Node.js 版本的构建脚本 bundle-a2ui.mjs,内容如下:
#!/usr/bin/env node
import { createHash } from "node:crypto";
import { promises as fs } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { spawn } from "node:child_process";
import { promisify } from "node:util";
const spawnAsync = (spawn);
__filename = (..);
__dirname = path.(__filename);
= path.(__dirname, );
= path.(, );
= path.(, );
= path.(, );
= path.(, );
() {
{
stat = fs.(dir);
stat.();
} {
;
}
}
() {
st = fs.(entryPath);
(st.()) {
entries = fs.(entryPath);
( entry entries) {
(path.(entryPath, entry), files);
}
files;
}
files.(entryPath);
files;
}
() {
p.(path.).();
}
() {
inputPaths = [
path.(, ),
path.(, ),
,
,
];
files = [];
( inputPath inputPaths) {
{
stat = fs.(inputPath);
(stat.() || stat.()) {
(inputPath, files);
}
} {
}
}
files.( (a).((b)));
hash = ();
( filePath files) {
rel = (path.(, filePath));
hash.(rel);
hash.();
content = fs.(filePath);
hash.(content);
hash.();
}
hash.();
}
() {
( {
proc = (command, args, {
...options,
: ,
: ,
});
proc.(, {
(code === ) {
();
} {
( ());
}
});
proc.(, reject);
});
}
() {
{
(!( ()) || !( ())) {
.();
process.();
}
currentHash = ();
shouldBuild = ;
{
previousHash = fs.(, );
outputExists = fs.().( ).( );
(previousHash.() === currentHash && outputExists) {
.();
shouldBuild = ;
}
} {
}
(shouldBuild) {
.();
(, [, , , , path.(, )]);
(, [, , , , path.(, )]);
fs.(, currentHash, );
.();
}
} (error) {
.();
.();
.(error);
process.();
}
}
();


