npx 启动不成功程序直接退出 @deepseek-ai/dsh (published package) silently exits with code 0 on Node < 24.2.0 — the consumer-side counterpart of #5082
#6115
Replies: 3 comments
|
锁定一下node版本吧,特么没事就给你们升级node |
|
I independently reproduced this with the published
One boundary clarification: I prepared a small fork-only reference implementation, based on upstream
Verification: 13 owner-local expected tests, 14 adjacent tests, and 27 existing built-CLI acceptance tests passed, along with the full build, lint, documentation, and package-hygiene checks. The expected tests distinguish simulated version-policy cases from the actual runtime matrix above; they also check import-only behavior and rejection when no CLI dependencies are available. Linux/Windows CI has not been run for this reference branch. Sharing this as supplemental evidence and a reference patch under the current CONTRIBUTING policy; no external PR opened. |
|
同样遇到该问题,升级node解决 |
Uh oh!
There was an error while loading. Please reload this page.
@deepseek-ai/dsh(published package) silently exits with code 0 on Node < 24.2.0 — the consumer-side counterpart of #5082关联与区别(重要,请勿当作 #5082 的重复)
本问题与 #5082 是同一个根因(
import.meta.main在 Node < 24.2.0 上为undefined),但发生在完全不同的表面上,且 #5082 建议的修复无法覆盖本问题:
scripts/*.ts,经 tsx 执行)@deepseek-ai/dsh的lib/bin.jsgit clone+pnpm run build的开发者npx/npm i的终端用户(无需构建)$ tsx scripts/build.ts后 exit 0,无产物 → 服务能起但/返回 404engines现状package.json有声明,但范围写错(含 24.0.x/24.1.0)apps/cli/package.json完全没有engines字段关键点:#5082 建议「把根
package.json的engines收紧为^22.19.0 || >=24.2.0」——该修复只作用于源码仓库,而用户实际安装的发布包
@deepseek-ai/dsh根本没有engines字段,npm 因此不会给出任何警告,失败也完全静默。两者需要分别修复。
已核对(
master分支,版本均为0.1.5-rc.1):环境
0.1.5-rc.1(0.1.3-alpha.2、0.1.5-alpha.1、0.1.5-alpha.2同样受影响)v24.0.011.3.0问题描述
在 Node 版本低于 24.2.0 的环境中,通过 npm 安装的
dsh执行任何命令都没有任何输出、没有报错、以退出码 0 正常退出,无法从任何信号判断问题所在。
复现步骤
实际行为
0在伪终端下(
script -qec "dsh --help" /dev/null)表现完全一致,排除 TTY 依赖。注意:连 commander 的
--help都不输出,说明代码根本没有执行到参数解析阶段。预期行为
应当正常启动;若 Node 版本不满足要求,应以非零退出码退出并打印可读的版本错误信息。
根因
源码位置:
apps/cli/src/bin.ts末尾发布产物:
node_modules/@deepseek-ai/dsh/lib/bin.js末尾(编译后)import.meta.main自 Node.js v24.2.0 起可用(v22 线另有回填版本,与 #5082 所述一致)。在 Node v24.0.0 上该属性求值为
undefined,导致if恒假 →runCli()从未被调用→ 进程什么都不做,直接以 0 退出。
独立验证
与 dsh 无关的最小复现:
绕过该守卫、显式调用入口函数后,dsh 功能完全正常(证明包本身无问题):
升级到 Node v24.21.0 后,原命令无需任何改动即恢复正常:
影响
这个故障模式极具误导性:用户会优先怀疑 npm 源、镜像、代理或网络问题,
因为没有任何信号指向 Node 版本。
在本次排查中已实测排除(均为正常):
npm view @deepseek-ai/dsh正常返回0.1.5-rc.1,-ddd日志显示npm http fetch GET 200_npx/*/node_modules/.bin/dsh存在)即:包下载正常、依赖安装正常,只是从未被执行。
且 #5082 报告于 2026-08-30,本问题在 2026-09-10 的
0.1.5-rc.1上依然复现 ——根因存续已逾 10 天,并已扩散到面向终端用户的发布产物。
建议修复
1. 给发布包补
engines声明(最关键,覆盖本 issue)apps/cli/package.json目前没有engines字段:2. 同时修正根
package.json的engines(覆盖 #5082)当前
^22.19.0 || >=24.0.0中的>=24.0.0包含了 24.0.x / 24.1.0,应收紧为^22.19.0 || >=24.2.0(与 #5082 建议一致)。3. 让失败可见(治本)
在
apps/cli/src/bin.ts入口增加自检,避免静默退出:或按 #5082 的建议,改用不依赖
import.meta.main的入口判断(如
process.argv[1]与import.meta.url对比),使声明范围内的 Node 行为一致。4. 文档标注最低版本
在 README / 安装说明中明确写出 Node 最低版本要求。
附:临时绕过方式
无法升级 Node 时,可用包装器显式调用入口函数:
All reactions