Skip to content
Discussion options

You must be logged in to vote

应该不是bun版本问题,我在本地bun1.3.2依然可以build,但是在vercel上面bun会额外多安装一些东西:

你本地运行 bun run build 根本没有执行到 wrap‑ansi 那段依赖链。

⚠️ 本地构建根本不会访问 wrap‑ansi
⚠️ wrap‑ansi 的 require 根本不会被执行
⚠️ 所以即使 node_modules 被 Bun 扁平化,本地也不会报错

本地看到成功,是因为:

❯ bun install   →   wrap‑ansi/node_modules/string-width 的错误没有触发
❯ bun run build → 根本不会 require wrap‑ansi

但是在 Vercel:

Vercel 构建使用 Node.js 的 ESM 模块加载器

wrap‑ansi 被 Astro 的某些内部 CLI 工具引用
(具体来源是:@astrojs/vercel 内部调用的 Pagefind CLI)

因此,在 Vercel:

🚨 wrap‑ansi 会被 require
🚨 require 时发现 node_modules 结构不标准
🚨 string-width 找不到
❌ 构建直接崩溃

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Muleizhang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant