Maaz Zindani

Loading the index…

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

TypeScript cannot find a new Prisma model on the client

ErrorProperty '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.

  • Applies to Prisma 6, Prisma 7, TypeScript 5, Next.js 15
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 import
  2. 2Match what you see, then jump to its fix

    1. 1The model exists in schema.prisma but prisma.<model> is red in the editorThe client was not regenerated after the schema changedFix
    2. 2The 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. 3The model exists, you generated, and the error remains in some files onlyThe code imports a different client than the one that was generatedFix

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.prisma

2Fix

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 --noEmit

Confirmed by prisma.io

Did this fix it?

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.prisma

2Fix

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 --noEmit

Confirmed by prisma.io

Did this fix it?

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/null

2Fix

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 --noEmit

Confirmed by prisma.io

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

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