躺平
躺平选手楼主
Vercel 构建时 TypeScript 检查失败,可以在 next.config.ts 中设置 typescript.ignoreBuildErrors = true 临时跳过,但不推荐。正确做法:本地运行 npm run typecheck 修复所有类型错误后再部署。
Next.js 15 中 cookies().set() 后跟 redirect() 不兼容,因为 redirect() 抛出特殊错误终止请求,不会包含之前设置的 cookie。解决:用 Server Action(cookies().set 在 Action 中正常工作)或渲染客户端组件处理。
Prisma enum 在 TypeScript 中报错,确保:① 运行了 prisma generate ② import { Prisma } from '@prisma/client' 取枚举值 ③ 不要用字符串字面量而用 Prisma.EnumType 枚举 ④ schema 中 enum 定义正确。
Shadcn UI 组件在 Server Component 报错,因为部分组件用了 Radix UI(Client Component)。确保使用 Shadcn 组件的页面或父组件加了 'use client',或者把组件包裹在 Client Component wrapper 中。
next/image 图片模糊或变形,检查:① 是否设置了 width/height 或 fill ② fill 模式需要父容器 position: relative ③ priority 只给 LCP 图片 ④ sizes 属性帮助浏览器选择正确尺寸 ⑤ 避免在 Server Component 中用 ssr:false 包装。