Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Prisma works locally but fails on Vercel with a stale client or a missing prisma command

ErrorPrismaClientInitializationError

Short answer

Vercel caches dependencies between deployments, so the generated Prisma Client can be out of date after a schema change. Add a postinstall script that runs prisma generate. If the build says prisma: command not found, move prisma from devDependencies into dependencies.

  • Applies to Prisma ORM 6 and 7, Next.js 15, Vercel (Nov 2026)
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open the failed deployment's build log on Vercel and read the lines around the Prisma step. They say whether generate ran or the prisma command was missing.

    grep -n -E "prisma" package.json
  2. 2Match what you see, then jump to its fix

    1. 1The app builds, then Prisma Client errors at runtime after you changed schema.prismaCached dependencies mean prisma generate never ranFix
    2. 2prisma: command not found in the build logprisma is a dev dependency, so the build cannot find itFix
    3. 3A preview deploy changed or broke the production schemaMigrations run on previews against the production databaseFix

What does the error look like?

  • PrismaClientInitializationError
  • prisma: command not found

Cause 1 of 3

Cached dependencies mean prisma generate never ran

1Check

Prisma's Vercel guide says Vercel automatically caches dependencies on deployment, which can leave Prisma Client out of date because nothing regenerates it.

grep -n -E "postinstall|\"build\"" package.json

2Fix

Add a postinstall script so the client is regenerated on every install. Committing the generated client is the other option the guide names.

{
  "scripts": {
    "postinstall": "prisma generate"
  }
}

3Verify

Redeploy and check the build log for the generate step, then open the page that used the database.

npx prisma generate

Confirmed by prisma.io

Did this fix it?

Cause 2 of 3

prisma is a dev dependency, so the build cannot find it

1Check

Prisma's guide notes prisma is a dev dependency by default and so may be missing during Vercel builds.

grep -n -B2 -A2 "\"prisma\"" package.json

2Fix

Move prisma into dependencies in package.json, then reinstall to refresh the lockfile.

{
  "dependencies": {
    "prisma": "^6.0.0"
  }
}

3Verify

The build log shows prisma generate finishing.

npm install

Confirmed by prisma.io

Did this fix it?

Cause 3 of 3

Migrations run on previews against the production database

1Check

The guide says production and preview environments both use the DATABASE_URL set when the project was imported, so a migration in a pull request can change the production schema.

# Vercel dashboard: Project > Settings > Environment Variables, read DATABASE_URL scopes

2Fix

Add a DATABASE_URL that applies only to the Preview environment and points at a second database.

# Vercel Environment Variables: add DATABASE_URL, scope Preview only, value = second database

3Verify

A preview deployment reads and writes the second database only.

# Check the preview app's data against the second database

Confirmed by prisma.io

Did this fix it?

How do I stop it coming back?

  • Keep postinstall prisma generate in package.json from the first deploy.
  • Give previews their own database through a Preview-only DATABASE_URL.
  • Run migrations in a vercel-build script rather than by hand.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.