I’m having trouble with
Executing a new wix app running npm run dev.
Working in
Dev Mode
Environment:
- Astro: 6.1.5
- [at]astrojs/cloudflare: 13.1.8
- [at]wix/astro: 2.13.0
- Node: (v24.15.0)
Description:
I just followed the instructions to create a WIX app.
But at when running npm run dev I get:
19:53:58 [wix] App Manifest updated. Refresh existing browser tabs to view the latest changes.
19:54:04 [ERROR] [vite] Internal server error: require is not defined
at runInRunnerObject (workers/runner-worker/index.js:106:3)
at _NonRunnablePipeline.getMiddleware (/home/will/Devel/External-Companies/yangteataiwan/line-payment-101/node_modules/.vite/deps_ssr/chunk-KISBL6D5.js?v=5595af8c:951:34)
at _RenderContext.create (/home/will/Devel/External-Companies/yangteataiwan/line-payment-101/node_modules/.vite/deps_ssr/chunk-IAPQODBZ.js?v=5595af8c:1386:32)
at DevApp.render (/home/will/Devel/External-Companies/yangteataiwan/line-payment-101/node_modules/.vite/deps_ssr/chunk-IAPQODBZ.js?v=5595af8c:2506:29)
at Object.handle [as fetch] (/home/will/Devel/External-Companies/yangteataiwan/line-payment-101/node_modules/.vite/deps_ssr/[at]astrojs_cloudflare_entrypoints_server.js?v=e0e58621:211:20)
at maybeCaptureError (workers/runner-worker/index.js:50:10)
Root Cause:
I was checking this issue with an IA and it seems to be this:
Astro 6’s Cloudflare adapter uses the
workerdruntime, which only supports ESM.
However, the entire[at]wix/ecosystem (including[at]wix/astro,[at]wix/essentials,
[at]wix/sdk,[at]wix/design-system, etc.) is compiled to CommonJS (cjs/builds).
Steps to Reproduce:
npm create wix-app[at]latestnpm run dev- Error appears immediately
Expected Behavior:
wix dev should work with Astro 6 + Cloudflare without require is not defined errors.
Actual Behavior:
Server crashes because workerd doesn’t support CommonJS require().
Workarounds Tried:
optimizeDeps.include— insufficient, too many CJS packagesssr.noExternal— did not resolve
Maybe I could downgrading to Astro 5 to make it works but is not a long-term solution
Request:
- Is it possible to migrate
[at]wix/astroand its dependencies to ESM? - Otherwise is there an official workaround for Astro 6 + Cloudflare compatibility. ?
NOTE
I replaced the at symbol with “[at]” to be able to post this, because the wix forum consider it as a reference to a user and because is my first post I cannot reference other users.
Any help is highly appreciated.
Regards!