I have a application in NextJS 13 and deploy it on Vercel.
I’m generating all content from Localess integration.
Locally the SSG is working properly. with : npm run build
and npm run dev
When I’m deploying the application to Vercel I’m receiving the next error in the building logs :
[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
Not sure from where the error is comming, as domain name is exposed piblicly from Firebase
2
Answers
Vercel is using node 18 by default. In case you use node 16 you will need to specify in package.json the following lines :
you will next warning in the CLI :
We will need more than just the error to grasp what’s going on man. Could you maybe link the repo or something like that so we could have some context?
Plus, the appDir is still very WIP so if it keeps throwing errors you might want to move it back to the pages directory for now.