What is the problem?
dev 能跑 build 却失败,几乎都是严格校验和环境差异:TypeScript 类型错、ESLint 当错误、SSR 里用了 window、环境变量缺失、import 大小写、依赖装错位置、动态导入——7 个最常见原因的真实成因和修复命令。
Quick solution
Treat this as a Codex troubleshooting issue. First confirm the environment, inputs, permissions, logs, and delivery boundary. Then use the linked deep guide for the full checklist before changing production code or promising a result.
Read the deep guideDetailed steps
- dev 用增量编译、不做完整类型检查、不跑生产优化;
- build 会做**全量 TypeScript 类型检查、ESLint、Tree-shaking、SSR 预渲染**,任何一步出错就整体失败。
- 用 `ignoreBuildErrors` / `ignoreDuringBuilds` 强行让 build 过,是把问题推到线上,能修就别用。
- 改 `tsconfig`、`next.config`、依赖文件前先有 Git 记录,方便回滚。
- [报错解释器](/tools/error-explainer):贴 build 日志自动归类
- [Codex 工具页](/tools/codex)
Commands or code
npx tsc --noEmitRisk notes
Confirm the real project environment, account permissions, platform rules, and output quality before delivery. Do not ship AI-generated changes without human review, and do not claim indexing, income, deployment success, or ranking improvements without measured evidence.