Struan Mclean
Struan Mclean

Reputation: 121

Cloudflare and next.js static exports not working?

It normally works but suddenly it stoped working and im not sure why. If you can help thanks!

logs

2022-11-24T13:14:56.98176Z  Executing user command: next build && next export
2022-11-24T13:14:57.075259Z /opt/buildhome/repo/node_modules/next/dist/build/index.js:344
2022-11-24T13:14:57.075558Z                     ...pageKeys.app ?? [], 
2022-11-24T13:14:57.075709Z                                      ^
2022-11-24T13:14:57.075852Z 
2022-11-24T13:14:57.075978Z SyntaxError: Unexpected token '?'
2022-11-24T13:14:57.076087Z     at wrapSafe (internal/modules/cjs/loader.js:1054:16)
2022-11-24T13:14:57.076193Z     at Module._compile (internal/modules/cjs/loader.js:1102:27)
2022-11-24T13:14:57.0763Z       at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2022-11-24T13:14:57.076409Z     at Module.load (internal/modules/cjs/loader.js:986:32)
2022-11-24T13:14:57.076516Z     at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2022-11-24T13:14:57.076621Z     at Module.require (internal/modules/cjs/loader.js:1026:19)
2022-11-24T13:14:57.076736Z     at require (internal/modules/cjs/helpers.js:72:18)
2022-11-24T13:14:57.076877Z     at Object.<anonymous> (/opt/buildhome/repo/node_modules/next/dist/cli/next-build.js:10:37)
2022-11-24T13:14:57.077002Z     at Module._compile (internal/modules/cjs/loader.js:1138:30)
2022-11-24T13:14:57.077111Z     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2022-11-24T13:14:57.082209Z Failed: build command exited with code: 1
2022-11-24T13:14:57.927713Z Failed: an internal error occurred

It exports the files and deploys to cloud flare

Upvotes: 2

Views: 447

Answers (1)

Jonathan Wieben
Jonathan Wieben

Reputation: 671

The error you are getting indicates that your Node version does not support the nullish coalescing operator, which is part of Node as of version 14. From reading the Cloudflare docs I understand that the default Node version is 12, which would match this suspicion.

The solution then would be to update your Cloudflare configuration to use a newer version (14+) of Node (see docs).

Upvotes: 2

Related Questions