Vercel:NextJS 13获取SSG数据时出错

mgdq6dx1  于 2023-03-18  发布在  其他
关注(0)|答案(2)|浏览(137)

我在NextJS 13中有一个应用程序,并将其部署在Vercel上。我从Localless集成中生成所有内容。
SSG在本地正常工作,其中:npm run buildnpm run dev当我将应用程序部署到Vercel时,我在构建日志中收到下一个错误:

[21:08:33.864] Running build in Washington, D.C., USA (East) – iad1
[21:08:33.919] Cloning REPO-NAME (Branch: main, Commit: ****)
[21:08:33.925] Skipping build cache, deployment was triggered without cache.
[21:08:34.274] Cloning completed: 354.752ms
[21:08:34.388] Running "vercel build"
[21:08:34.828] Vercel CLI 28.16.15
[21:08:35.067] Installing dependencies...
[21:08:42.601] 
[21:08:42.601] added 271 packages in 7s
[21:08:42.601] 
[21:08:42.601] 102 packages are looking for funding
[21:08:42.601]   run `npm fund` for details
[21:08:42.618] Detected Next.js version: 13.2.4
[21:08:42.621] Detected `package-lock.json` generated by npm 7+...
[21:08:42.621] Running "npm run build"
[21:08:42.920] 
[21:08:42.920] > build
[21:08:42.920] > next build
[21:08:42.920] 
[21:08:43.409] warn  - You have enabled experimental features (appDir, typedRoutes) in next.config.js.
[21:08:43.410] warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
[21:08:43.410] 
[21:08:43.410] info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback
[21:08:43.433] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[21:08:43.433] This information is used to shape Next.js' roadmap and prioritize features.
[21:08:43.433] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[21:08:43.433] https://nextjs.org/telemetry
[21:08:43.433] 
[21:08:43.566] info  - Creating an optimized production build...
[21:08:48.773] info  - Compiled successfully
[21:08:48.776] info  - Linting and checking validity of types...
[21:08:51.085] info  - Collecting page data...
[21:08:54.464] TypeError: fetch failed
[21:08:54.464]     at Object.fetch (node:internal/deps/undici/undici:14062:11)
[21:08:54.464]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[21:08:54.465]   cause: TypeError: Cannot read properties of undefined (reading 'reason')
[21:08:54.465]       at makeAppropriateNetworkError (node:internal/deps/undici/undici:6736:171)
[21:08:54.465]       at schemeFetch (node:internal/deps/undici/undici:13492:16)
[21:08:54.465]       at node:internal/deps/undici/undici:13422:26
[21:08:54.465]       at mainFetch (node:internal/deps/undici/undici:13439:11)
[21:08:54.465]       at httpRedirectFetch (node:internal/deps/undici/undici:13692:14)
[21:08:54.465]       at httpFetch (node:internal/deps/undici/undici:13638:28)
[21:08:54.465]       at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[21:08:54.465]       at async schemeFetch (node:internal/deps/undici/undici:13546:18)
[21:08:54.466]       at async node:internal/deps/undici/undici:13422:20
[21:08:54.466]       at async mainFetch (node:internal/deps/undici/undici:13418:20)
[21:08:54.466] }
[21:08:54.467] 
[21:08:54.468] > Build error occurred
[21:08:54.471] Error: Failed to collect page data for /[...slug]
[21:08:54.471]     at /vercel/path0/node_modules/next/dist/build/utils.js:1055:15
[21:08:54.471]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[21:08:54.471]   type: 'Error'
[21:08:54.471] }
[21:08:54.526] Error: Command "npm run build" exited with 1
[21:08:55.059] BUILD_FAILED: Command "npm run build" exited with 1

不确定错误来自何处,因为域名从Firebase中暴露

6tr1vspr

6tr1vspr1#

我们需要的不仅仅是错误来理解发生了什么,你能不能把回购协议或类似的东西联系起来,这样我们就可以有一些背景?
另外,appDir仍然是非常WIP的,所以如果它一直抛出错误,您可能需要暂时将其移回pages目录。

iqxoj9l9

iqxoj9l92#

Vercel默认使用节点18。如果使用节点16,则需要在package.json中指定以下行:

"engines": {
    "node": "16"
  },

您将在CLI中看到下一个警告:

Warning: Due to "engines": { "node": "16" } in your `package.json` file, the Node.js Version defined in your Project Settings ("18.x") will not apply. Learn More: http://vercel.link/node-version

相关问题