Skip to content
Latchkey

Strapi "strapi build" failed in CI

Strapi compiles its admin panel with a bundler during strapi build. The build fails when a required environment variable is absent, when the bundler runs out of memory on a small runner, or when a plugin cannot be compiled.

What this error means

A strapi build (or npm run build) step fails with a bundler error, "JavaScript heap out of memory", or "Missing ... environment variable" before the dist/ build completes.

Strapi
[ERROR] Error: Missing apiToken salt. Please set the env var ADMIN_JWT_SECRET ...
    at .../node_modules/@strapi/strapi/dist/...
error Command failed with exit code 1.

Common causes

A required env var is unset at build time

Strapi reads secrets like APP_KEYS or ADMIN_JWT_SECRET during build; if they are not set, the build throws.

The bundler exhausts memory

On a small runner the admin build can exceed the default Node heap and crash with "heap out of memory".

How to fix it

Provide the required env at build time

  1. Set APP_KEYS, ADMIN_JWT_SECRET, and other required vars from secrets.
  2. Expose them to the build step environment.
  3. Re-run the build.
.github/workflows/ci.yml
env:
  APP_KEYS: ${{ secrets.APP_KEYS }}
  ADMIN_JWT_SECRET: ${{ secrets.ADMIN_JWT_SECRET }}
  NODE_ENV: production

Raise the Node heap for the build

Give Node more memory so the admin bundle does not exhaust the default heap.

Terminal
NODE_OPTIONS=--max-old-space-size=4096 npm run build

How to prevent it

  • Set all build-time secrets in the CI environment.
  • Increase --max-old-space-size on memory-constrained runners.
  • Cache node_modules so plugin compilation is consistent.

Frequently asked questions

What causes ""strapi build" failed"?
Strapi reads secrets like APP_KEYS or ADMIN_JWT_SECRET during build; if they are not set, the build throws.
How do I fix "strapi build" failed?
Provide the required env at build time

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card