SyntaxError deploying NextJS site

17:51:30.162	Executing user command: npx @cloudflare/next-on-pages --experimental-minify
17:51:35.478	/opt/buildhome/.npm/_npx/1347/lib/node_modules/@cloudflare/next-on-pages/dist/index.js:6013
17:51:35.478	              ({ type, expression }) => type === "ExpressionStatement" && expression?.type === "CallExpression" && expression.callee?.type === "MemberExpression" && expression.callee.object?.type === "AssignmentExpression" && expression.callee.object.left?.object?.name === "self" && expression.callee.object.left.property?.value === "webpackChunk_N_E" && expression.arguments?.[0]?.elements?.[1]?.type === "ObjectExpression"
17:51:35.478	                                                                                     ^
17:51:35.478	
17:51:35.479	SyntaxError: Unexpected token '.'
17:51:35.479	    at wrapSafe (internal/modules/cjs/loader.js:1054:16)
17:51:35.479	    at Module._compile (internal/modules/cjs/loader.js:1102:27)
17:51:35.479	    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
17:51:35.479	    at Module.load (internal/modules/cjs/loader.js:986:32)
17:51:35.479	    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
17:51:35.479	    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
17:51:35.479	    at internal/main/run_main_module.js:17:47
17:51:35.549	Failed: build command exited with code: 1
17:51:36.498	Failed: an internal error occurred

Try bumping your NODE_VERSION env variable to 16 to support the newer optional chaining syntax.

Be very wary about next-on-pages though. There’s lots of issues with it, and I’ve seen users waste hours of time trying to get it working, or running well with any real-world projects. It’s in a state right now that I couldn’t personally recommend it due to lack of maintenance and support, and generally encourage people to consider an alternative solution like Netlify or Vercel for their projects.

I’ll give it a try, thanks!

I’ve looked at Vercel too, is it easy to use custom domains to host a site there? If so it may be a good option for me but I am yet to try it out.

I believe it is just as easy, yes. Netlify is also a great option. I’d just be wary of next-on-pages at this time for the reason mentioned previously.

Oh my god thank you so much, that was the only thing that was breaking my deployments and I’ve finally got it fixed!

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