Karthik Kamalakannan Karthik Kamalakannan Design Founder & CEO of Skcript.
3 min read

Fixing Astro site build on Cloudflare Pages with Bun

You might be facing issues deploying your Astro website on Cloudflare Pages using Bun. Here is a solution for you.

Astro + Cloudflare Pages + Bun is a great combination for building and deploying static websites. But recently, you might have faced some issues with builds failing with your Astro site on Cloudflare Pages using Bun.

/opt/buildhome/repo/node_modules/string-width/index.js

[ERR_REQUIRE_ESM]: require() of ES Module /opt/buildhome/repo/node_modules/strip-ansi/index.js from /opt/buildhome/repo/node_modules/string-width/index.js not supported.

This is due to the fact that Cloudflare Pages has not yet updated the latest Bun version. To make it work, all you need to do is to simply add an environment variable to your Cloudflare Pages project.

Environment variable: Key: BUN_VERSION Value: 1.1.29

This will force Cloudflare Pages to use Bun 1.1.29 instead of the latest version.

This is a temporary solution until Cloudflare Pages updates the Bun version.

Karthik Kamalakannan
Karthik Kamalakannan

Karthik is the Founder & CEO of Skcript. Over the last , he has built highly scalable B2B software for both Skcript and its clients. Combining minimalist design with rock-solid product stability, his leadership helps companies ship enduring products at unprecedented speeds.