I’m building two different projects in Svelte with SvelteKit and I’m facing the same error in both project deployments in Vercel.
error during build:
Error [ERR_REQUIRE_ESM]: require() of ES Module /vercel/path0/node_modules/string-width/index.js from /vercel/path0/node_modules/wide-align/align.js not supported.
Instead change the require of index.js in /vercel/path0/node_modules/wide-align/align.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/vercel/path0/node_modules/wide-align/align.js:2:19)
error: script "build" exited with code 1
Error: Command "bun run build" exited with 1
It’s interesting to note that this error is only thrown when the build is triggered by a push to my GitHub repository. If I retry the deployment manually, it passes each time.
Hey @mardi66! I wasn’t able to replicate this issue with a SvelteKit starter project. Do you have a public repo or minimal reproducible example that we can use to debug this together?
I know SvelteKit is designed to work with ESM, so it’s important to make sure everything in the project uses that same syntax. It looks like something in the project uses wide-align and the require() on this line is throwing the error.