Skip to content
Latchkey

How to Run Prisma in CI Without Engine or Client Errors

Prisma fails in CI when the generated client is missing, the query-engine binary does not match the runner OS, or DATABASE_URL is not set - none of which a plain install fixes.

Prisma is not a typical package: after npm install you must run prisma generate to produce the client, and it downloads a query-engine binary built for a specific OS/OpenSSL. CI breaks when the client is not generated, the binaryTargets do not match the runner, or commands run without a DATABASE_URL.

Why it fails in CI

The Prisma client is code-generated, and the query engine is a native binary matched to the platform. A fresh CI checkout has no generated client, and a binary built for your laptop’s OS may not match the runner’s Debian/OpenSSL, so the client cannot initialize. Migration and introspection commands also need a reachable database.

  • @prisma/client did not initialize yet. Please run "prisma generate".
  • Query engine library for current platform "debian-openssl-3.0.x" could not be found.
  • Environment variable not found: DATABASE_URL on migrate/db commands.

Install it reliably

Run prisma generate after install (a postinstall script or an explicit step), declare the runner’s platform in binaryTargets, and provide DATABASE_URL to any command that touches the DB. For migrations against a fresh DB, run prisma migrate deploy.

schema.prisma
// schema.prisma - include the CI runner's platform
generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "debian-openssl-3.0.x"]
}

Cache & speed

Generate the client and run migrations as explicit steps, with DATABASE_URL set (often pointing at a service container). Cache the Prisma engine download and node_modules so the engine binary is not re-fetched every run.

.github/workflows/ci.yml
env:
  DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test
steps:
  - run: npm ci
  - run: npx prisma generate
  - run: npx prisma migrate deploy   # apply migrations to the CI DB
  - uses: actions/cache@v4
    with:
      path: ~/.cache/prisma
      key: prisma-${{ hashFiles('prisma/schema.prisma') }}

Common errors

ErrorCauseFix
did not initialize yet. Run prisma generateClient not generatedAdd npx prisma generate step
Query engine for "debian-openssl-3.0.x" not foundbinaryTargets mismatchAdd the runner platform to binaryTargets
Environment variable not found: DATABASE_URLNo DB URLSet DATABASE_URL (service container)
migrate dev prompts / fails in CIInteractive command in CIUse prisma migrate deploy

Key takeaways

  • Always run prisma generate after install in CI.
  • Set binaryTargets to include the runner platform (e.g. debian-openssl-3.0.x).
  • Provide DATABASE_URL and use prisma migrate deploy, not migrate dev.

Related guides

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