Buil fail

I'm encountering issues building my Astro application, which uses Svelte for components and Supabase for the database. The application is hosted on Cloudflare Workers. While local development is working fine, the build process on Cloudflare is failing. The root of the problem seems to be the micromatch module. I'm getting an error related to micromatch during the build process. I've exhausted the suggestions provided by AI assistants like ChatGPT, Gemini, and Copilot, but none have resolved the issue.
02:01:16 [ERROR] [vite] x Build failed in 631ms
[commonjs--resolver] [plugin vite:resolve] Cannot bundle Node.js built-in "util" imported from "node_modules\micromatch\index.js". Consider disabling ssr.noExternal or remove the built-in dependency.
file: E:/Cloudflare/my-astro-app/node_modules/micromatch/index.js
Stack trace:
at getRollupError (file:///E:/Cloudflare/my-astro-app/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
at Object.error (file:///E:/Cloudflare/my-astro-app/node_modules/rollup/dist/es/shared/node-entry.js:19733:20)
at Object.handler (file:///E:/Cloudflare/my-astro-app/node_modules/vite/dist/node/chunks/dep-BaOMuo4I.js:65575:15)
at async PluginDriver.hookFirstAndGetPlugin (file:///E:/Cloudflare/my-astro-app/node_modules/rollup/dist/es/shared/node-entry.js:19818:28)
at async ModuleLoader.resolveId (file:///E:/Cloudflare/my-astro-app/node_modules/rollup/dist/es/shared/node-entry.js:18912:15)`
02:01:16 [ERROR] [vite] x Build failed in 631ms
[commonjs--resolver] [plugin vite:resolve] Cannot bundle Node.js built-in "util" imported from "node_modules\micromatch\index.js". Consider disabling ssr.noExternal or remove the built-in dependency.
file: E:/Cloudflare/my-astro-app/node_modules/micromatch/index.js
Stack trace:
at getRollupError (file:///E:/Cloudflare/my-astro-app/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
at Object.error (file:///E:/Cloudflare/my-astro-app/node_modules/rollup/dist/es/shared/node-entry.js:19733:20)
at Object.handler (file:///E:/Cloudflare/my-astro-app/node_modules/vite/dist/node/chunks/dep-BaOMuo4I.js:65575:15)
at async PluginDriver.hookFirstAndGetPlugin (file:///E:/Cloudflare/my-astro-app/node_modules/rollup/dist/es/shared/node-entry.js:19818:28)
at async ModuleLoader.resolveId (file:///E:/Cloudflare/my-astro-app/node_modules/rollup/dist/es/shared/node-entry.js:18912:15)`
Can anyone help? I would be very grateful.
No description
1 Reply
Walshy
Walshy3mo ago
micromatch dependency is trying to use a nodejs api. Your best bet is enabling node compat - https://developers.cloudflare.com/workers/runtime-apis/nodejs/ If it's still not working (using APIs not supported yet) then your best bet is finding another package
Cloudflare Docs
Node.js compatibility | Cloudflare Workers docs
Implemented Node.js runtime APIs and enablement instructions for your Worker project.
Want results from more Discord servers?
Add your server