Skip to content
Latchkey

Astro "astro build" failed (build errored) in CI

Astro compiles pages and components, runs any integrations, and (for SSR/hybrid) bundles the server output. When astro build errors, it exits non-zero and stops the job. The first error message, not the "build errored" summary, is what to fix.

What this error means

A step running astro build (often npm run build) prints one or more errors and exits non-zero before deploy.

astro
05:12:44 [build] Building static entrypoints...
05:12:45 [build] Error Could not resolve "../components/Card.astro" from
"src/pages/index.astro"
 error   Build failed with 1 error

Common causes

A page, component, or content file cannot be resolved or compiled

A wrong import path, a component syntax error, or an integration failure stops the build on the first hard error.

A dependency or integration missing on the runner

CI ran without a full install, so a package or integration the build needs is absent.

How to fix it

Read the first error and fix the file

  1. Scroll up to the first Error (or Vite/Rollup error) and note the file it names.
  2. Fix the import path, component, or content issue at that location.
  3. Re-run astro build locally to confirm it exits zero.
Terminal
npx astro build

Install cleanly before building

A resolve error can simply be a missing dependency; run a clean lockfile install first.

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

How to prevent it

  • Run astro build before pushing so errors surface locally.
  • Use npm ci so CI installs exactly what you tested.
  • Match import casing to filenames for case-sensitive Linux runners.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →