安装openclaw-cn运行pnpm build命令时报错。

scripts/bundle-a2ui.sh: line 31: node: command not found

https://www.kuazhi.com/post/716228501.html文章里的解决方法有效。搬运过来。

执行完 pnpm install 后,按照常规流程运行:

pnpm build

结果报错:

scripts/bundle-a2ui.sh: line 31: node: command not found

❓ 问题:Bash 脚本在 Windows 上找不到 node

原因

OpenClaw 使用了一个 Unix 风格的 shell 脚本 bundle-a2ui.sh 来构建前端 UI(A2UI)。但在 Windows 上,该脚本由 Git Bash 执行,而 Git Bash 未继承系统 PATH,导致无法找到 node.exe。

✅ 解决方案(采用)

放弃 Bash 脚本,改用纯 Node.js 脚本,实现跨平台兼容。

1)创建 scripts/bundle-a2ui.mjs:

// scripts/bundle-a2ui.mjs

// OpenClaw A2UI Bundle Placeholder Generator

// For public repository users who do not have access to private A2UI source code.

// This script creates a minimal valid ES module to satisfy TypeScript compilation.

import fs from 'node:fs';

import path from 'node:path';

import { createHash } from 'node:crypto';

import { fileURLToPath } from 'node:url';

// ── Resolve project root directory correctly on Windows and Unix ──

const __filename = fileURLToPath(import.meta.url);

const __dirname = path.dirname(__filename);

const ROOT_DIR = path.resolve(__dirname, '..'); // openclaw/ root

// ── Define output paths ──

const OUTPUT_DIR = path.join(ROOT_DIR, 'src', 'canvas-host', 'a2ui');

const OUTPUT_FILE = path.join(OUTPUT_DIR, 'a2ui.bundle.js');

const HASH_FILE = path.join(OUTPUT_DIR, '.bundle.hash');

// ── Ensure output directory exists ──

fs.mkdirSync(OUTPUT_DIR, { recursive: true });

// ── Generate placeholder content (valid ES module) ──

const placeholderContent = `

// Auto-generated placeholder for A2UI

// Source code is not available in the public OpenClaw repository.

// This file exists only to satisfy build dependencies.

export const A2UI = {

version: '0.0.0-placeholder',

render: () => {

throw new Error('A2UI runtime is not available in this build.');

}

};

`.trim() + '\n';

// ── Write the bundle file ──

fs.writeFileSync(OUTPUT_FILE, placeholderContent);

// ── Compute and write hash to prevent unnecessary rebuilds ──

const hash = createHash('sha256').update(placeholderContent).digest('hex');

fs.writeFileSync(HASH_FILE, hash);

// ── Success message ──

console.log('✅ A2UI placeholder bundle created successfully.');

console.log(` Bundle: ${OUTPUT_FILE}`);

console.log(` Hash: ${HASH_FILE}`);

2)并在 package.json 中替换脚本: D:\Program\OpenClaw\openclaw\package.json 文件下: .scripts.canvas:a2ui:bundle 修改为以下值。

{

"scripts": {

...,

"canvas:a2ui:bundle": "node --import tsx scripts/bundle-a2ui.mjs",

...

}

}

 此方案彻底绕过对 bash 和 node 环境的依赖。

Logo

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

更多推荐