Demo, all content is generated
Question

Prisma on Vercel: 'Prisma has detected that this project was built on Vercel'

Solved · 402 views · asked by lily_chen · edited

Added a column to my Prisma schema, pushed, and production crashes with:

PrismaClientInitializationError: Prisma has detected that this project was built on Vercel, which caches dependencies. This leads to an outdated Prisma Client because Prisma's auto-generation isn't triggered.

The first deploy worked fine.

What I’ve tried

Redeployed without cache from the Vercel dashboard. That worked once, but the next normal deploy broke again.

Comment

3 answers

Marked as helpful by the asker
jonas_k · edited

Vercel reuses cached node_modules, so Prisma's install hook that generates the client doesn't run when dependencies haven't changed. Generate it yourself on every build:

"scripts": {
  "postinstall": "prisma generate",
  "build": "prisma generate && next build"
}

Either line alone is enough, I like it in build because it's obvious.

Comment
that was quick. thanks, deployed twice to be sure, both fine lily_chen · edited
rune_a · edited

If you're on pnpm 10: it no longer runs dependency install scripts unless you allow them, so Prisma's own postinstall can be skipped even outside Vercel. Explicit prisma generate in your build script covers that too.

Comment
anjali_p · edited

Same error class on Netlify, same fix. Anything with a generate step (Prisma, Drizzle kit, GraphQL codegen) should be in the build script, not rely on install hooks.

Comment