Docusaurus build fails using all defaults

I’m attempting to deploy a Docusaurus site to Pages, but it fails every time.
So I started over, and just followed the tutorial from Cloudflare exactly. I installed the default site, then connected it to a git repository, then attempted to deploy it, and it failed. It looks like there’s a syntax error somewhere, but I’m not sure how to correct it. I assumed it should just work, considering there’s a tutorial and presets, etc. for Docusaurus and Pages.

Here’s the relevant logs:

19:35:40.304	> [email protected] build /opt/buildhome/repo
19:35:40.304	> docusaurus build
19:35:40.377	(node:1259) ExperimentalWarning: The ESM module loader is experimental.
19:35:40.384	file:///opt/buildhome/repo/node_modules/@docusaurus/core/bin/docusaurus.mjs:30
19:35:40.385	process.env.BABEL_ENV ??= 'development';
19:35:40.385	                       ^
19:35:40.385	SyntaxError: Unexpected token '?'
19:35:40.385	    at Loader.moduleStrategy (internal/modules/esm/translators.js:81:18)
19:35:40.385	    at async link (internal/modules/esm/module_job.js:37:21)

Thanks in advance, and sorry if this seems kind of dumb, I’m totally new to pages and static sites.

Upon further looking around, it looks like the syntax error isn’t something I can fix easily? I found it, however, node_modules isn’t included in the repo, so I assume Cloudflare handles it?

Can you try a newer node version? Add an environment variable to the project called NODE_VERSION and set it to something like 18 or 16.

Thanks! That fixed it!

For future reference I set the version to 18

1 Like

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