TypeScript cannot find a new Prisma model on the client
Property 'post' does not exist on type 'PrismaClient'Short answer
Prisma Client is generated code. Adding a model to schema.prisma changes nothing in the client until you run prisma generate. Run it, restart the TypeScript server, and check that the model name is written with a lowercase first letter and that you import from the right output path.
Fix it fast
1Find out which cause you have
Check which generator and output path the schema uses, then compare it with the path your code imports PrismaClient from.
grep -n -A4 "generator" prisma/schema.prisma grep -rn "PrismaClient" --include=*.ts --include=*.tsx src app lib 2>/dev/null | grep import2Match what you see, then jump to its fix
- 1
The model exists in schema.prisma but prisma.<model> is red in the editorThe client was not regenerated after the schema changedFix - 2
The error names a property such as Post or posts, while the model is written model PostThe property name does not match the model nameFix - 3
The model exists, you generated, and the error remains in some files onlyThe code imports a different client than the one that was generatedFix
- 1
What does the error look like?
Property 'post' does not exist on type 'PrismaClient'
Cause 1 of 3
The client was not regenerated after the schema changed
1Check
The docs say to run prisma generate after you change the schema or generator settings, or after you pull schema changes from a teammate or another branch.
git log -1 --format=%cd -- prisma/schema.prisma2Fix
Generate the client again. To keep it from happening on deploys, run the same command in a postinstall script or before the production build.
npx prisma generate
# package.json
"scripts": {
"postinstall": "prisma generate"
}3Verify
Restart the TypeScript server in your editor, then run the type check.
npx tsc --noEmitConfirmed by prisma.io
Cause 2 of 3
The property name does not match the model name
1Check
A model User in the schema is used as prisma.user, and model Post as prisma.post. The client property takes the model name with a lowercase first letter.
grep -n "^model " prisma/schema.prisma2Fix
Use the lowercase-first form of the model name.
// schema: model Post { ... }
const posts = await prisma.post.findMany()3Verify
The type check passes and the editor shows the model's methods.
npx tsc --noEmitConfirmed by prisma.io
Cause 3 of 3
The code imports a different client than the one that was generated
1Check
With the prisma-client generator, output is required and the client lives at that path. Import PrismaClient from there, not from the package, and make sure every file uses the same import.
grep -n "output" prisma/schema.prisma
grep -rn "from \"@prisma/client\"\|from '@prisma/client'" src app lib 2>/dev/null2Fix
Point the import at the generated output folder.
// schema.prisma
generator client {
provider = "prisma-client"
output = "./generated"
}
// code
import { PrismaClient } from "../prisma/generated/client"3Verify
Run the type check again.
npx tsc --noEmitConfirmed by prisma.io
How do I stop it coming back?
- Run prisma generate in postinstall and before the production build.
- After pulling a branch that touched schema.prisma, generate before you start the dev server.
- Keep one shared file that creates and exports the PrismaClient, so there is one import path.
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- TaskvareA task and project-management suite: React on the web, Flutter on mobile, TypeScript underneath.
Related fixes
Back end
Prisma cannot find a query engine for debian-openssl in Docker
Query engine library for current platform "debian-openssl-1.1.x" could not be found
Prisma Client ships a query engine built for one OS and OpenSSL version.
2 causes, each with a fixWeb apps
TypeScript rejects the authorize function of the Credentials provider
A custom field you return from authorize is missing on the User or Session type
The authorize callback must return either a user object or null.
3 causes, each with a fixWeb apps
The user is undefined inside the NextAuth session callback
session.user.id is undefined
With JWT sessions, NextAuth gives the session callback a token, not a user.
3 causes, each with a fixWeb apps
Upgrading to Next.js 16: middleware becomes proxy, and the other things that break
Missing Required default.js for Parallel Route
Next.js 16 renames middleware.ts to proxy.ts and its exported function to proxy.
6 causes, each with a fixWeb apps
next build stops because of TypeScript errors
How to disable typescript for failing my builds with nextjs?
next build runs a TypeScript check and fails the build when it finds type errors.
2 causes, each with a fixWeb apps
TypeScript cannot resolve import './globals.css' in Next.js
ts(2882)
TypeScript now checks imports like import './globals.css' when noUncheckedSideEffectImports is on, and it finds no type for a CSS file.
2 causes, each with a fix