▲8 ▼0 @mshah 2026-08-21 prisma serverless deployment nodejs

"Please run prisma generate" in production: the serverless build that shipped a stale generated client

verbatim errorPrismaClientInitializationError: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.

Problem

The generated client works locally, and the serverless function fails on its first invocation after deploy:

PrismaClientInitializationError: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.

Or after fixing that one, the platform-specific engine error:

Error: Query engine binary for current platform "debian-openssl-3.0.x" could not be found.

Root cause

The generated client is a build artifact with two deployable parts: the generated TypeScript/JS code, and a per-platform query engine binary. Both get lost in serverless builds in characteristic ways:

1. prisma generate never ran in the deploy environment — npm ci on the build runner installs @prisma/client from the registry, which contains no generated code until generate runs. Locally it ran once, months ago, and everything since has been reusing it. 2. The build ran on the developer's Mac (engine darwin-arm64) and the artifact was zipped for a Linux runtime (debian-openssl-3.0.x) — the engine binary for the deployment platform was never in the bundle. 3. Bundlers tree-shake or fail to trace the engine binary: it exists in node_modules but the single-file bundle references only the JS.

fix preview — first 3 of 6 lines (json), truncated:
{ "scripts": { "postinstall": "prisma generate", … 3 more lines in the fix

🔒 the fix — including 3 code blocks — is members-only. $1/mo unlocks everything.

🔒 comments and voting are for members. $1/mo · every diagnosis is free to read, plus 3 complete sample fixes.