Remix "remix build" failed (command exited non-zero) in CI
The classic Remix compiler (remix build) produces both a server bundle and a browser bundle. When either fails, the CLI exits non-zero and the job stops. The real error is the first message above the failure line, not the summary.
What this error means
A step running remix build (or npm run build) prints one or more errors and then exits with a non-zero code, failing the job before deploy.
Building Remix app in production mode...
Error: Build failed with 1 error:
app/routes/_index.tsx:3:19: ERROR: Could not resolve "~/lib/db.server"
at failureErrorWithLogCommon causes
A module the build cannot resolve
A route imports a path that does not exist at build time (a moved file, a wrong alias, or a dependency not installed on the runner), so the bundle fails.
A type or syntax error the compiler surfaces
The esbuild-based compiler stops on the first hard error; a bad import, an unsupported syntax, or a missing export halts the whole build.
How to fix it
Read the first ERROR line, not the summary
- Scroll up to the first
ERROR:the compiler printed and note the file and column. - Fix the underlying import, path, or syntax at that location.
- Re-run
remix buildlocally to confirm the compiler exits zero.
npx remix buildInstall dependencies before building
A resolve error can just mean a dependency was never installed on the runner. Run a clean install with the committed lockfile first.
npm ci
npm run buildHow to prevent it
- Run
remix buildin a pre-push hook so resolve errors surface locally. - Commit the lockfile and use
npm ciso CI installs exactly what you tested. - Keep path aliases in tsconfig and the bundler config in sync.