PrismaVercelDeploy

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

  1. Add a postinstall script so every install, including Vercel's, regenerates the client: in package.json, "postinstall": "prisma generate".
  2. Keep the prisma package in dependencies (not only devDependencies) so prisma generate can run during the production install.
  3. Set DATABASE_URL (and DIRECT_URL if 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.
  4. After an AI changes schema.prisma, commit the schema, let postinstall run on the host, and do not assume a generate the agent ran on your laptop is what Vercel will use. If a query still says Unknown argument, the client is stale: run npx prisma generate locally, confirm the field exists, and redeploy with a clean build.
  5. If you also need to apply migrations on deploy, that is a separate step (prisma migrate deploy in the build or a release command). prisma generate only rebuilds the client; it does not change the database.

Example

{
  "scripts": {
    "postinstall": "prisma generate",
    "build": "prisma generate && next build"
  }
}
Don't: Don't delete the Vercel cache as your only fix, and don't copy a generated client from your laptop into git as a workaround. Make generate part of install so every deploy does it.

Copy-paste fix prompt

3 · The fix promptPaste into Cursor, Claude Code, Codex, Lovable, Bolt, Replit or v0
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.

Related fixes

← All fixes · Still stuck? Use the diagnose-first prompt