TypeScript cannot find PrismaClient after switching to the prisma-client generator
Your error
error TS2305: Module '"@prisma/client"' has no exported member 'PrismaClient'.3 more lines it can showFix it fast
Most common cause, 1 of 3Imports still point at @prisma/client
Change each import to the client file in your output folder.
// before
// import { PrismaClient, Prisma } from '@prisma/client'
// after (output = "../generated/prisma", file in src/)
import { PrismaClient, Prisma } from '../generated/prisma/client'Short answer
The prisma-client generator, the default in Prisma ORM 7, writes the client into the folder named by output, for example generated/prisma, and no longer into node_modules. Importing PrismaClient from @prisma/client then fails. Run prisma generate and import from the generated client file, such as ../generated/prisma/client, using a relative path or an alias your tsconfig knows.
Which cause do you have?
Read the generator block. Its provider and output decide where the client lives and therefore what the import must say.
grep -A4 "^generator" prisma/schema.prisma
ls generated/prisma 2>/dev/null | headThen find the line you see in this list and open its fix:
- 1Imports still point at @prisma/client
TS2305 on '@prisma/client', or at runtime: Cannot find module '.prisma/client/default' - 2The import path names the folder, or is not relative
TS2307 for 'generated/prisma' or './generated/prisma' even though the folder exists - 3The generated folder does not exist on this machine
Works locally, fails in CI, Docker or on a fresh clone
What does the error look like?
error TS2305: Module '"@prisma/client"' has no exported member 'PrismaClient'.error TS2307: Cannot find module 'generated/prisma' or its corresponding type declarations.error TS2307: Cannot find module './generated/prisma' or its corresponding type declarations.Error: Cannot find module '.prisma/client/default'
Cause 1 of 3
Imports still point at @prisma/client
You seeTS2305 on '@prisma/client', or at runtime: Cannot find module '.prisma/client/default'
Check
With provider = "prisma-client" nothing is generated inside node_modules, so the @prisma/client package has no generated PrismaClient to re-export. The upgrade guide shows the import moving from @prisma/client to the generated path.
grep -rn "from '@prisma/client'" src app libFix
Change each import to the client file in your output folder. Types such as Prisma and model types come from the same file.
// before
// import { PrismaClient, Prisma } from '@prisma/client'
// after (output = "../generated/prisma", file in src/)
import { PrismaClient, Prisma } from '../generated/prisma/client'Verify
tsc reports no TS2305, and the app starts.
npx tsc --noEmitConfirmed by prisma.io
Cause 2 of 3
The import path names the folder, or is not relative
You seeTS2307 for 'generated/prisma' or './generated/prisma' even though the folder exists
Check
The generator writes several TypeScript files (client.ts, models.ts, enums.ts and others) with no index file, so importing the bare folder does not resolve. A path without ./ or ../ is treated as a package name unless tsconfig maps it.
ls generated/prisma/*.tsFix
Import the client file by a relative path, or define a paths alias in tsconfig. An alias only teaches the type checker; plain Node.js does not read it, so use one only when your bundler or runner (Next.js, Vite, tsx) resolves the same alias.
// relative
import { PrismaClient } from '../../generated/prisma/client'
// or tsconfig.json
{
"compilerOptions": {
"paths": { "@db/*": ["./generated/prisma/*"] }
}
}
// then
import { PrismaClient } from '@db/client'Verify
The editor resolves the import and the build passes.
npx tsc --noEmitConfirmed by prisma.io
Cause 3 of 3
The generated folder does not exist on this machine
You seeWorks locally, fails in CI, Docker or on a fresh clone
Check
prisma init adds /generated/prisma to .gitignore, so a clean checkout has no client until prisma generate runs. Builds that skip that step see a missing module.
grep -n generated .gitignore
grep -n "prisma generate" package.json Dockerfile .github/workflows/*.yml 2>/dev/nullFix
Generate the client as part of the build, after npm install and before the TypeScript compile.
// package.json
"scripts": {
"build": "prisma generate && tsc"
}
# Dockerfile
COPY prisma ./prisma
COPY prisma.config.ts ./
RUN npx prisma generateVerify
A fresh clone builds with npm ci && npm run build and the generated folder appears.
rm -rf generated && npm run build && ls generated/prismaConfirmed by prisma.io
How do I stop it coming back?
- Keep one db module that imports from the generated path; the rest of the code imports that module.
- Make prisma generate part of every build script, never a manual step.
- After changing output, search the code for the old import path before committing.
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.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.