Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4133 pages
Node.js, PHP and APIs

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 show

Fix it fast

Most common cause, 1 of 3

Imports still point at @prisma/client

Change each import to the client file in your output folder.

Fix
// before
// import { PrismaClient, Prisma } from '@prisma/client'

// after (output = "../generated/prisma", file in src/)
import { PrismaClient, Prisma } from '../generated/prisma/client'
Did this fix it?
Full steps for this cause: check, fix, verify

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.

  • Applies to Prisma ORM 7.10, TypeScript 7.0, Node.js 24
  • Updated
  • By Maaz Zindani, Senior Software Engineer

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.

Run this first
grep -A4 "^generator" prisma/schema.prisma
ls generated/prisma 2>/dev/null | head

Then find the line you see in this list and open its fix:

  1. 1Imports still point at @prisma/clientTS2305 on '@prisma/client', or at runtime: Cannot find module '.prisma/client/default'
  2. 2The import path names the folder, or is not relativeTS2307 for 'generated/prisma' or './generated/prisma' even though the folder exists
  3. 3The generated folder does not exist on this machineWorks 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.

Check
grep -rn "from '@prisma/client'" src app lib

Fix

Change each import to the client file in your output folder. Types such as Prisma and model types come from the same file.

Fix
// 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.

Verify
npx tsc --noEmit

Confirmed by prisma.io

Did this fix it?

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.

Check
ls generated/prisma/*.ts

Fix

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.

Fix
// 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.

Verify
npx tsc --noEmit

Confirmed by prisma.io

Did this fix it?

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.

Check
grep -n generated .gitignore
grep -n "prisma generate" package.json Dockerfile .github/workflows/*.yml 2>/dev/null

Fix

Generate the client as part of the build, after npm install and before the TypeScript compile.

Fix
// package.json
"scripts": {
  "build": "prisma generate && tsc"
}

# Dockerfile
COPY prisma ./prisma
COPY prisma.config.ts ./
RUN npx prisma generate

Verify

A fresh clone builds with npm ci && npm run build and the generated folder appears.

Verify
rm -rf generated && npm run build && ls generated/prisma

Confirmed by prisma.io

Did this fix it?

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:

Next step

Want this handled for good?

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