从源码快速安装 openclaw
直接通过 npm install -g openclaw@latest 安装openclaw 一直失败
npm install -g openclaw@latest
npm error code 128
npm error An unknown git error occurred
npm error command git --no-replace-objects ls-remote ssh://git@github.com/whiskeysockets/libsignal-node.git
npm error git@github.com: Permission denied (publickey).
npm error fatal: Could not read from remote repository.
npm error
npm error Please make sure you have the correct access rights
npm error and the repository exists.
npm notice
npm notice New major version of npm available! 10.9.4 -> 11.9.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.9.0
npm notice To update run: npm install -g npm@11.9.0
npm notice
npm error A complete log of this run can be found in: /home/cmdb-root/.npm/_logs/2026-02-05T12_56_08_186Z-debug-0.log
原因就是:网络超时(无法从 GitHub 克隆) 或 编译环境缺失。
就换了个思路,通过源码安装,但是源码安装也太慢了,只浅clone就好了:
# 只克隆最后一层提交
$ git clone --depth 1 https://github.com/OpenClaw/OpenClaw.git
$ cd OpenClaw
$ npm install --ignore-scripts
$ npm run build
在执行 npm run build的时候又报错了:
root@xxx:/opt/openclaw/OpenClaw# npm run build
npm warn Unknown project config "allow-build-scripts". This will stop working in the next major version of npm.
> openclaw@2026.2.4 build
> pnpm canvas:a2ui:bundle && tsdown && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/write-build-info.ts && node --import tsx scripts/write-cli-compat.ts
sh: 1: pnpm: not found
root@pccyber02:/opt/openclaw/OpenClaw# npm run build
npm warn Unknown project config "allow-build-scripts". This will stop working in the next major version of npm.
> openclaw@2026.2.4 build
> pnpm canvas:a2ui:bundle && tsdown && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/write-build-info.ts && node --import tsx scripts/write-cli-compat.ts
sh: 1: pnpm: not found
原因分析:
OpenClaw 的构建脚本内部硬编码使用了 pnpm(一个比 npm 更快、更节省空间的包管理器),而你的系统中目前只安装了 npm。
由于构建脚本里包含了 pnpm canvas:a2ui:bundle 这样的指令,即使你用 npm run build 启动,它在执行中途也会因为找不到 pnpm 而中断。
解决方案:npm install -g pnpm
$ npm install -g pnpm

build 成功了,但是依然找不到 openclaw 的命令,继续配置 pnmp 环境
$ pnpm setup

$ source ~/.bashrc
$ pnpm link --global

安装成功了~

浙公网安备 33010602011771号