You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
现象
pnpm run build,瞬间结束,无任何输出。不报错,退出码 0。但没有任何构建产物,.dsh-build/client-build-environment.json也不存在。pnpm run check:all、pnpm run verify-cordis-config、pnpm run verify-doc-site-fragments、pnpm run verify-runtime-closure等脚本。全部都是静默退出 exit 0。根因
Node.js bug #58660 :
import.meta.main在 TypeScript 入口文件下返回undefined。Node 24.2.0 才修复,但本仓库 package.json 声明的engines.node: "^22.19.0 || >=24.0.0"允许使用 24.0.x。本项目 5 个脚本用
if (import.meta.main)作为 CLI 入口 guard:scripts/build.tspnpm run buildscripts/run-gates.tspnpm run check:all、pnpm run check:ciscripts/verify-cordis-config.tspnpm run verify-cordis-configscripts/verify-doc-site-fragments.tspnpm run docs:build内部调用scripts/verify-runtime-closure.tspnpm run verify-runtime-closure在 Node 24.0.x 上,guard 条件永远是
false,main()没被调用,脚本直接跑完模块求值、退出 0,看上去什么都没执行。engines.node已经声明支持这一范围,所以用户按声明使用 Node 24.0.x 是合理的,属于仓库真实 bug。复现步骤
再单独执行其中一个脚本观察:
node --import tsx scripts/verify-cordis-config.ts # (无任何输出,exit 0)修复方案
把
if (import.meta.main)替换为跨版本兼容的入口检测:pathToFileURL()而非模板字符串,避免安装路径含空格、#、?、%时百分号编码不匹配(参考 cyberuni/cyberplace#272 )本地修复验证
修复后再次运行其中最轻量的脚本:
node --import tsx scripts/verify-cordis-config.ts # verify-cordis-config: 130 config files passed. ✅5 个脚本全部正常执行。commit + pre-push hook(完整 typecheck + build)通过。
补丁文件
附带修复补丁(5 files changed, +15 insertions, -5 deletions):
相关链接
import.meta.main在 TS 入口下失效file://模板字面量百分号编码陷阱的踩坑记录)0001-fix-scripts-replace-import.meta.main-guard-with-path.patch
All reactions