Prisma Client missing after a Vercel deploy
Prisma has detected that this project was built on Vercel, which caches `node_modules`. Please run `prisma generate` and try to import it again.
In short: The deploy used a cached node_modules that does not include a Prisma Client generated from your current schema, so the app boots without the models you just added.
Why it happens
Prisma Client is generated code (prisma generate), not a normal package you import as-is. Locally, a post-install or a manual generate creates it in node_modules. On Vercel, dependency caching can reuse a node_modules folder from an earlier build and skip that generate, so the client is missing or stale. The warning names Vercel's cache; you may also see @prisma/client did not initialize yet or, after an AI adds a column, Unknown argument on a field that exists in schema.prisma but not in the generated client. A second common miss is putting prisma only in devDependencies so a production install has no CLI to run generate.
How to fix it
- Add a
postinstallscript so every install, including Vercel's, regenerates the client: inpackage.json,"postinstall": "prisma generate". - Keep the
prismapackage independencies(not onlydevDependencies) soprisma generatecan run during the production install. - Set
DATABASE_URL(andDIRECT_URLif your schema uses it) in the Vercel project for Production and Preview, then redeploy. A generate can succeed and the app can still fail later if the database URL is missing at runtime. - After an AI changes
schema.prisma, commit the schema, letpostinstallrun on the host, and do not assume a generate the agent ran on your laptop is what Vercel will use. If a query still saysUnknown argument, the client is stale: runnpx prisma generatelocally, confirm the field exists, and redeploy with a clean build. - If you also need to apply migrations on deploy, that is a separate step (
prisma migrate deployin the build or a release command).prisma generateonly rebuilds the client; it does not change the database.
Example
{
"scripts": {
"postinstall": "prisma generate",
"build": "prisma generate && next build"
}
}
Copy-paste fix prompt
I'm getting this error in my app: Prisma has detected that this project was built on Vercel, which caches `node_modules`. Please run `prisma generate` and try to import it again. [Paste the full error, stack trace, and the file it points to here] Likely cause: The deploy used a cached node_modules that does not include a Prisma Client generated from your current schema, so the app boots without the models you just added. Task: The Vercel deploy is missing or using a stale Prisma Client (cache skipped prisma generate, or Unknown argument after a schema change). Add a postinstall (and/or build) script that runs prisma generate, keep the prisma package in dependencies, and ensure DATABASE_URL is set on Vercel. Don't commit a handmade client or disable the cache as the only fix. Rules: - First explain the root cause in 2 sentences and list the files you'll change. - Make the smallest change that fixes it. Don't refactor unrelated code. - Don't disable security or checks (RLS, auth, signature verification, type checking, CORS allow-all) to make the error disappear. - Never print or hard-code secret keys. - Finish by telling me exactly how to verify the fix.
Common with: Cursor, Claude Code, v0, Codex. Last reviewed 2026-11-15.