[BUG] 发现构建脚本在 pnpm 11 下失败的问题:runScript 错误地用 Node 执行包管理器 #3532
Replies: 1 comment
|
The root-cause classification is correct: rc.8 assumes I would avoid making A safer cross-platform helper should classify the concrete entrypoint:
The helper should be shared by I expanded the existing runbook in place (rather than publishing a duplicate): canonical revision 2 · visual execution map. Disclosure: I maintain the independent SandBase DeepSeek Harness Handbook. |
Uh oh!
There was an error while loading. Please reload this page.
环境信息
问题描述
运行
pnpm run build时出现以下错误:该错误表明 Node.js 正在尝试将 pnpm 可执行文件当作 JavaScript 模块加载。根据 pnpm 安装方式的不同,该文件可能是 ELF 二进制文件或 POSIX shell 脚本,但两者都不是合法的 JavaScript 代码。
根本原因
在
scripts/build.ts文件中,runScript函数使用了以下方式执行包脚本:该代码实际执行的是:
也就是说,它使用 Node.js 去运行包管理器的入口文件。在旧版 pnpm 中,入口文件可能是 JavaScript 文件,但在 pnpm 11 中,入口变成了 shell 脚本(
POSIX shell script)或 ELF 二进制文件。Node 无法解析这些格式,因此抛出SyntaxError或ELF错误。建议的修复方案
不要用 Node 去执行包管理器,而是直接运行包管理器的入口文件,并让系统 shell 处理 shebang:
此修改在 Linux/macOS(入口为 shell 脚本)和 Windows(入口为
.cmd文件)上均可正常工作。shell: true选项确保系统 shell 能够正确解析文件。补充说明
pnpm run build:lib没有问题,只有build.ts中的包装逻辑会失败。期望的行动
请更新
scripts/build.ts,使用shell: true直接执行包管理器入口文件。或者,根据包管理器类型检测并采用合适的执行方式。感谢!
All reactions