Skip to content
Latchkey

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.

remix
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 failureErrorWithLog

Common 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

  1. Scroll up to the first ERROR: the compiler printed and note the file and column.
  2. Fix the underlying import, path, or syntax at that location.
  3. Re-run remix build locally to confirm the compiler exits zero.
Terminal
npx remix build

Install 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.

.github/workflows/ci.yml
npm ci
npm run build

How to prevent it

  • Run remix build in a pre-push hook so resolve errors surface locally.
  • Commit the lockfile and use npm ci so CI installs exactly what you tested.
  • Keep path aliases in tsconfig and the bundler config in sync.

Frequently asked questions

What causes ""remix build" failed"?
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.
How do I fix "remix build" failed?
Read the first ERROR line, not the summary

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card