Remix "remix vite:build" failed in CI
With the Vite plugin, remix vite:build runs a client build and an SSR build. A failure in either stops the job. Vite prints the failing module and reason above the exit line; that first error is what to fix.
What this error means
A step running remix vite:build (often via npm run build) prints a Vite build error and exits non-zero before deploy.
vite v5.2.0 building SSR bundle for production...
[commonjs--resolver] Failed to resolve entry for package "some-lib".
error during build:
RollupError: Could not resolve entry module.Common causes
A dependency Vite cannot resolve or bundle
A package with a broken exports map, a CJS module Vite cannot interop, or a missing entry fails the Rollup step Vite uses.
A server-only import in the client build
A Node built-in or server module pulled into the client build breaks the client bundle under Vite.
How to fix it
Read the Vite/Rollup error and adjust
- Find the first
error during build:orRollupErrorline and the module it names. - For a CJS interop issue, add the package to
ssr.noExternaloroptimizeDeps. - For a server-only leak, move the import into a loader or a
.servermodule.
// vite.config.ts
export default defineConfig({ ssr: { noExternal: ["some-lib"] } });Install and build cleanly
Rule out a partial install by running npm ci before the Vite build.
npm ci
npm run buildHow to prevent it
- Test
remix vite:buildlocally before pushing. - Use
ssr.noExternalfor packages Vite cannot externalize cleanly. - Keep server-only code out of the client build.