Can't build static Astro site on Cloudflare Pages (can locally)

For Workes & Pages, what is the name of the domain?

i16-me.pages.dev

What is the error message?

3:16:27.411 Error [ERR_REQUIRE_ESM]: require() of ES Module /opt/buildhome/repo/node_modules/string-width/index.js from /opt/buildhome/repo/node_modules/ansi-align/index.js not supported. 13:16:27.411 Instead change the require of /opt/buildhome/repo/node_modules/string-width/index.js in /opt/buildhome/repo/node_modules/ansi-align/index.js to a dynamic import() which is available in all CommonJS modules. 13:16:27.411 at Object. (/opt/buildhome/repo/node_modules/ansi-align/index.js:3:21) { 13:16:27.411 code: ‘ERR_REQUIRE_ESM’ 13:16:27.411 }

What is the issue or error you’re encountering

doesn’t let me build on cloudflare pages

What steps have you taken to resolve the issue?

tried to make node version same as local system

What are the steps to reproduce the issue?

create an Astro project
attach it to CF pages
try to build it

Screenshot of the error

2 Likes

I have the same problem now…

The problem might be related to bun since is being used to install the project dependencies. I won’t go further but I managed to get it working by deleting the node_modules directory and installing everything with npm, everything in the “build command”.