Next.js Vercel 部署错误:无法收集 /api/favourites/[drivenSchoolId] 的页面数据

问题描述 投票:0回答:1

我正在尝试将 Next.js 应用程序部署到 Vercel,但遇到与特定 API 路由相关的构建错误。错误消息表明收集 /api/favourites/[driveSchoolId] 的页面数据失败,构建过程退出,代码为 1。以下是错误日志的相关部分:

错误信息:

  at fa (/vercel/path0/node_modules/@prisma/client/runtime/library.js:33:69)
    at new t (/vercel/path0/node_modules/@prisma/client/runtime/library.js:131:739)
    at 13543 (/vercel/path0/.next/server/app/api/favourites/[drivingSchoolId]/route.js:1:3921)
    at t (/vercel/path0/.next/server/webpack-runtime.js:1:128)
    at 91782 (/vercel/path0/.next/server/app/api/favourites/[drivingSchoolId]/route.js:1:2942)
    at t (/vercel/path0/.next/server/webpack-runtime.js:1:128)
    at 40100 (/vercel/path0/.next/server/app/api/favourites/[drivingSchoolId]/route.js:1:1267)
    at t (/vercel/path0/.next/server/webpack-runtime.js:1:128)
    at t (/vercel/path0/.next/server/app/api/favourites/[drivingSchoolId]/route.js:1:4006)
    at /vercel/path0/.next/server/app/api/favourites/[drivingSchoolId]/route.js:1:4041 {
  clientVersion: '5.16.2',
  errorCode: undefined
}
> Build error occurred
Error: Failed to collect page data for /api/favourites/[drivingSchoolId]
    at /vercel/path0/node_modules/next/dist/build/utils.js:1268:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  type: 'Error'
}
Error: Command "npm run build" exited with 1
next.js deployment vercel
1个回答
0
投票

我也面临着完全相同的问题。我正在使用 Prisma 查询数据库,这就是 API 路由失败的原因。 如果您使用的是 prisma,请在 vercel 项目设置中更改构建命令,如下所示

  1. 在仪表板上,单击您的项目
  2. 单击“设置”选项卡
  3. 在“构建和开发设置”下将“构建”命令覆盖为
    npx prisma generate && next build
  4. 重新部署应用程序
© www.soinside.com 2019 - 2024. All rights reserved.