一、项目背景
Clawdbot(Moltbot)是一款支持 WhatsApp、Telegram 等通道的私人 AI 助手,可运行在本地设备。本文记录从源码部署到 WebChat 验证的完整过程及常见问题解决方案。
二、环境准备:Windows 优先使用 WSL2
Windows 原生 CMD 部署易报错,推荐使用 WSL2(Ubuntu/Debian 镜像)。
- 启用 WSL2:在 Windows 功能中勾选'适用于 Linux 的 Windows 子系统'和'虚拟机平台',重启后安装 Ubuntu 22.04。
- 配置系统:更新源并升级系统
sudo apt update && sudo apt upgrade -y。 - 安装 Git:
sudo apt install git,验证git --version。
三、Node.js 版本要求
仓库文档要求 Node≥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 构建提示:
OpenClaw 在 Windows 上推荐使用 WSL2。若在原生 Windows 构建需 bash 支持。检查是否有 Git 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;
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);}}{
(){ ({ 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.();}}();


