dsh plugin add 对带 BOM 的 package.json 会直接 JSON.parse 崩溃 #2798
Fantasymax
started this conversation in
General
Replies: 1 comment
|
Confirmed on rc.6. Repro is the code itself. Why. Fix today. Re-save as UTF-8 without BOM. Scan for others: Fix upstream. Strip BOM before JSON.parse at both call sites, or use |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
在 VPS 上装 dsh-mcp-manager 的时候踩到一个坑,记录一下,顺便看要不要在 CLI 侧兜个底。
现象
dsh plugin --profile web add dsh-mcp-manager执行后,pnpm 那边明明装成功了,但 dsh 的 reconcile 阶段直接抛异常退出:结果是包进了 dependencies,bundle 没进
dsh.profile.bundles,exit 1。原因
这个包的 package.json 开头带了一个 UTF-8 BOM:
报错里那个引号后面的不可见字符就是它,不拿 od 看一眼根本发现不了。
临时处理
把 BOM 去掉再重新 add 一次就正常了:
建议
readProfileManifest在 parse 前剥一下前导 BOM 就行,一行的事:Node 自己加载 CJS 模块时也有这步(stripBOM)。第三方包的数据质量没法控制,CLI 侧免疫掉比让用户对着这个报错猜半天要好。
All reactions