Build command exited with code: 1

I’m trying to deploy Next.js in Cloudflare Pages through Github, but I’m getting this error, while I followed the steps from the Cloudflare GUI. What am I doing wrong?

00:43:08.964 Executing user command: npx @cloudflare/next-on-pages --experimental-minify
00:43:16.202 /opt/buildhome/.npm/_npx/1136/lib/node_modules/@cloudflare/next-on-pages/dist/index.js:3771
00:43:16.202 value = parts[1] ?? null;
00:43:16.202 ^
00:43:16.202 SyntaxError: Unexpected token ‘?’
00:43:16.203 at wrapSafe (internal/modules/cjs/loader.js:1054:16)
00:43:16.203 at Module._compile (internal/modules/cjs/loader.js:1102:27)
00:43:16.203 at Object.Module._extensions…js (internal/modules/cjs/loader.js:1158:10)
00:43:16.203 at Module.load (internal/modules/cjs/loader.js:986:32)
00:43:16.203 at Function.Module._load (internal/modules/cjs/loader.js:879:14)
00:43:16.203 at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
00:43:16.203 at internal/main/run_main_module.js:17:47
00:43:16.355 Failed: build command exited with code: 1
00:43:17.132 Failed: error occurred while running build command

?? is newer syntax that the default Node.js version in the Pages build image doesn’t support (it uses Node.js 12 today).

You can fix this by setting a NODE_VERSION env var to something modern like 18. There are also other things you will need to set for next-on-pages - be sure to follow the instructions at GitHub - cloudflare/next-on-pages: CLI to build and develop Next.js apps for Cloudflare Pages.


Thanks for your fast reply! How and where I do this? :sweat_smile:

Run through the instructions in the next-on-pages repo and it should guide you through this:

1 Like

Thanks @cherryjimbo

Just for more details if it can help someone, I just added in the settings > Environment variables for both production and preview: NODE_VERSION : 18.

1 Like

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