My nextjs app doesn't build on CF Pages. I keep getting an error

Hi,

I keep getting an error when deploying nextjs app (html only) to CF pages. It works on my local machine and I can preview the site but on CF Pages it just gets stuck. Can anyone help with this? Thanks… My log is below.

2022-11-26T09:44:44.744689Z Cloning repository…
2022-11-26T09:44:45.849214Z From https://github.com/yucelm/updated-node-nextjs
2022-11-26T09:44:45.849761Z * branch eb88a3d0c4b8ac67e1692f6f794836efcb75b290 → FETCH_HEAD
2022-11-26T09:44:45.850232Z
2022-11-26T09:44:45.889975Z HEAD is now at eb88a3d Update index.js
2022-11-26T09:44:45.890394Z
2022-11-26T09:44:46.06726Z
2022-11-26T09:44:46.110386Z Success: Finished cloning repository files
2022-11-26T09:44:46.790958Z Installing dependencies
2022-11-26T09:44:46.800184Z Python version set to 2.7
2022-11-26T09:44:49.87644Z v12.18.0 is already installed.
2022-11-26T09:44:50.855625Z Now using node v12.18.0 (npm v6.14.4)
2022-11-26T09:44:51.051537Z Started restoring cached build plugins
2022-11-26T09:44:51.067139Z Finished restoring cached build plugins
2022-11-26T09:44:51.506022Z Attempting ruby version 2.7.1, read from environment
2022-11-26T09:44:54.521533Z Using ruby version 2.7.1
2022-11-26T09:44:54.83717Z Using PHP version 5.6
2022-11-26T09:44:54.987106Z 5.2 is already installed.
2022-11-26T09:44:55.012978Z Using Swift version 5.2
2022-11-26T09:44:55.013937Z Started restoring cached node modules
2022-11-26T09:44:55.033098Z Finished restoring cached node modules
2022-11-26T09:44:55.235547Z Installing NPM modules using NPM version 6.14.4
2022-11-26T09:44:56.035409Z npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I’ll try to do my best with it!
2022-11-26T09:45:06.673364Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/[email protected] (node_modules/@next/swc-android-arm64):
2022-11-26T09:45:06.673615Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/[email protected]: wanted {os:android,arch:arm64} (current: {os:linux,arch:x64})
2022-11-26T09:45:06.673763Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/[email protected] (node_modules/@next/swc-darwin-x64):
2022-11-26T09:45:06.673871Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/[email protected]: wanted {os:darwin,arch:x64} (current: {os:linux,arch:x64})
2022-11-26T09:45:06.673993Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/[email protected] (node_modules/@next/swc-freebsd-x64):
2022-11-26T09:45:06.674102Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/[email protected]: wanted {os:freebsd,arch:x64} (current: {os:linux,arch:x64})
2022-11-26T09:45:06.674207Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/[email protected] (node_modules/@next/swc-linux-arm-gnueabihf):
2022-11-26T09:45:06.674322Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/[email protected]: wanted {os:linux,arch:arm} (current: {os:linux,arch:x64})
2022-11-26T09:45:06.674433Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/[email protected] (node_modules/@next/swc-linux-arm64-gnu):
2022-11-26T09:45:06.674545Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/[email protected]: wanted {os:linux,arch:arm64} (current: {os:linux,arch:x64})
2022-11-26T09:45:06.674664Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/[email protected] (node_modules/@next/swc-darwin-arm64):
2022-11-26T09:45:06.674776Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/[email protected]: wanted {os:darwin,arch:arm64} (current: {os:linux,arch:x64})
2022-11-26T09:45:06.67488Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/[email protected] (node_modules/@next/swc-win32-arm64-msvc):
2022-11-26T09:45:06.674986Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/[email protected]: wanted {os:win32,arch:arm64} (current: {os:linux,arch:x64})
2022-11-26T09:45:06.675079Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/[email protected] (node_modules/@next/swc-win32-x64-msvc):
2022-11-26T09:45:06.675169Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/[email protected]: wanted {os:win32,arch:x64} (current: {os:linux,arch:x64})
2022-11-26T09:45:06.675258Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/[email protected] (node_modules/@next/swc-linux-arm64-musl):
2022-11-26T09:45:06.675379Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/[email protected]: wanted {os:linux,arch:arm64} (current: {os:linux,arch:x64})
2022-11-26T09:45:06.675474Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/[email protected] (node_modules/@next/swc-win32-ia32-msvc):
2022-11-26T09:45:06.675568Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/[email protected]: wanted {os:win32,arch:ia32} (current: {os:linux,arch:x64})
2022-11-26T09:45:06.675665Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @next/[email protected] (node_modules/@next/swc-android-arm-eabi):
2022-11-26T09:45:06.675755Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @next/[email protected]: wanted {os:android,arch:arm} (current: {os:linux,arch:x64})
2022-11-26T09:45:06.675843Z
2022-11-26T09:45:06.677926Z added 18 packages from 45 contributors and audited 29 packages in 10.668s
2022-11-26T09:45:06.689505Z
2022-11-26T09:45:06.689694Z 2 packages are looking for funding
2022-11-26T09:45:06.689826Z run npm fund for details
2022-11-26T09:45:06.689966Z
2022-11-26T09:45:06.690087Z found 0 vulnerabilities
2022-11-26T09:45:06.690234Z
2022-11-26T09:45:06.715591Z NPM modules installed
2022-11-26T09:45:07.180446Z Installing Hugo 0.54.0
2022-11-26T09:45:08.007101Z Hugo Static Site Generator v0.54.0-B1A82C61A/extended linux/amd64 BuildDate: 2019-02-01T10:04:38Z
2022-11-26T09:45:08.026131Z Started restoring cached go cache
2022-11-26T09:45:08.071056Z Finished restoring cached go cache
2022-11-26T09:45:08.228504Z go version go1.14.4 linux/amd64
2022-11-26T09:45:08.245436Z go version go1.14.4 linux/amd64
2022-11-26T09:45:08.248847Z Installing missing commands
2022-11-26T09:45:08.249174Z Verify run directory
2022-11-26T09:45:08.249462Z Executing user command: next build && next export
2022-11-26T09:45:08.348442Z /opt/buildhome/repo/node_modules/next/dist/build/index.js:344
2022-11-26T09:45:08.349081Z …pageKeys.app ?? ,
2022-11-26T09:45:08.349387Z ^
2022-11-26T09:45:08.34956Z
2022-11-26T09:45:08.349715Z SyntaxError: Unexpected token ‘?’
2022-11-26T09:45:08.35027Z at wrapSafe (internal/modules/cjs/loader.js:1054:16)
2022-11-26T09:45:08.350795Z at Module._compile (internal/modules/cjs/loader.js:1102:27)
2022-11-26T09:45:08.351233Z at Object.Module._extensions…js (internal/modules/cjs/loader.js:1158:10)
2022-11-26T09:45:08.351755Z at Module.load (internal/modules/cjs/loader.js:986:32)
2022-11-26T09:45:08.35224Z at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2022-11-26T09:45:08.352757Z at Module.require (internal/modules/cjs/loader.js:1026:19)
2022-11-26T09:45:08.352946Z at require (internal/modules/cjs/helpers.js:72:18)
2022-11-26T09:45:08.353086Z at Object. (/opt/buildhome/repo/node_modules/next/dist/cli/next-build.js:10:37)
2022-11-26T09:45:08.353233Z at Module._compile (internal/modules/cjs/loader.js:1138:30)
2022-11-26T09:45:08.353385Z at Object.Module._extensions…js (internal/modules/cjs/loader.js:1158:10)
2022-11-26T09:45:08.360939Z Failed: build command exited with code: 1
2022-11-26T09:45:12.760735Z Failed: an internal error occurred

Have you set the NODE_VERSION environment variable to match your local node version? By default, pages uses node 12 which is old.

Hi @yucelm

It have so many problems i have deployed my demo nextjs app from repo to Cloudflare and netlify. Netlify always build without any issue where Cloudflare keep throwing issues. There are so many limitations for example after spending days to debug and fix the Cloudflare issues it now show that functions have a limit of only 1 mb.

My advice will be that it is not something which is ready to use you should better wait unless you have many hours to waste on debuging Cloudflare build. it is a painfull option comparing to vercel or netlify

thanks

Seriously? I dodn’t know that. I use Node V18. I just checked and CF pages supports up to V17. Why they don’t offer the lastest stable version? I mean, Version 12 as standard?

Yes, I have tried Netlify and it works fine. I wanted to use CF pages because I also use it for DNS and I like their global network coverage. It is really a bummer that we have to go through so many issues to get a clean deployment.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.