The error, verbatim
Jump to the fix ↓D:\project\node_modules\.prisma\client\default.js:43
throw new Error('@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.');
^
Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
at new PrismaClient (D:\project\node_modules\.prisma\client\default.js:43:11)
Tested on
- prisma / @prisma/client
- 6.19.3 and 7.10.0
- npm
- 11.9.0, 11.19.0, 12.2.0
- Node
- 24.14.0 (Windows), 24.21.0 (Ubuntu, WSL)
- OS
- Windows 11 Pro + Ubuntu 24.04
Contents
@prisma/client doesn’t contain your client. It contains a placeholder that throws this error until prisma generate writes the real one, built from your schema.prisma. So the message is literally true: generate hasn’t run, or didn’t finish, in the copy of node_modules your app is loading.
The confusing part is that npm install is supposed to run it for you. I reproduced four situations where it doesn’t, plus what changed in Prisma 7, where you don’t get this message at all:
| Situation | Message you get |
|---|---|
| Install didn’t generate (Windows, or schema added after install) | @prisma/client did not initialize yet |
npm ci --ignore-scripts |
Cannot find module '.prisma/client/default' |
| npm 12 blocked Prisma’s install script | Cannot find module '.prisma/client/default' |
| Prisma 7, generate never ran | Named export 'PrismaClient' not found (ESM), does not provide an export named 'PrismaClient' (TypeScript), or Cannot find module '.prisma/client/default' (CommonJS) |
The fix
Run it once to unblock yourself:
npx prisma generate✔ Generated Prisma Client (v6.19.3) to .\node_modules\@prisma\client in 215msThen stop depending on the install doing it. Add it to your own scripts in package.json:
"scripts": {
"postinstall": "prisma generate"
}A project’s own postinstall is a different thing from a dependency’s install script. That’s why the line above keeps working on npm 12, where Prisma’s script is blocked.
On Windows, the install didn’t generate for me
Same package.json, same lockfile, same prisma/schema.prisma, Prisma 6.19.3:
- On Ubuntu (WSL, npm 11.19.0),
npm ciprinted✔ Generated Prisma Client (v6.19.3)during the install, and the app ran. - On Windows 11 (npm 11.9.0),
npm ciran@prisma/client’s postinstall without any error, generated nothing, and the app threwdid not initialize yet. It happened from PowerShell and from Git Bash, and runningnpm rebuild @prisma/clientchanged nothing.
The script is written to fail silently. It looks for the Prisma CLI by resolving the prisma package, and Prisma 6’s package points its entry at ./build/types.js, a file that isn’t in the published package (I checked 6.6.0 through 6.19.3). So that lookup always fails, and the script falls back to running prisma -v on the PATH. That evidently worked on Linux and not on this Windows machine. I didn’t trace that last step further, but the fix above doesn’t depend on it.
The same thing happens on any OS if you add schema.prisma after installing, because the install already ran with no schema to generate from.
npm ci --ignore-scripts (and CI templates that use it)
Skipping install scripts skips Prisma’s too, so not even the placeholder gets written:
Error: Cannot find module '.prisma/client/default'
Same cause, different message. The project-level postinstall doesn’t help here either, because --ignore-scripts skips it too.
When you install with --ignore-scripts, generate as its own build step:
npm ci --ignore-scripts
npx prisma generatenpm 12 blocks Prisma’s install script
npm 12 doesn’t run dependencies’ install scripts unless you approve them (more on that in npm 12 breaking changes, tested). On Ubuntu, a clean npm ci with npm 12.2.0 warned:
npm warn install-scripts 3 packages had install scripts blocked because they are not covered by allowScripts:
npm warn install-scripts @prisma/client@6.19.3 (postinstall: node scripts/postinstall.js)
npm warn install-scripts @prisma/engines@6.19.3 (postinstall: node scripts/postinstall.js)
The app then failed with Cannot find module '.prisma/client/default'. The postinstall in the fix solves it. If you’d rather let Prisma’s own script run, approve it by name:
"allowScripts": {
"@prisma/client": true,
"@prisma/engines": true,
"prisma": true
}npm i prisma gave you Prisma 8
If npx prisma generate itself fails with No command registered for `generate` , the CLI you installed is the Prisma 8 release candidate, which npm currently serves as prisma@latest. Generate never runs, so you end up here. That one has its own fix: prisma generate not working: “No command registered”.
Prisma 7 throws different errors
Prisma 7.10.0 doesn’t ship the placeholder, so the same mistake (no generate) surfaces as a module error instead. Which one depends on how you import:
ESM (.mjs): SyntaxError: Named export 'PrismaClient' not found. The requested module '@prisma/client' is a CommonJS module...
TypeScript: SyntaxError: The requested module '@prisma/client' does not provide an export named 'PrismaClient'
CommonJS: Error: Cannot find module '.prisma/client/default'
The ESM message even suggests import pkg from '@prisma/client'. That changes nothing here: the module still has nothing in it until generate runs. The fix is the same prisma generate.
Once that’s done, Prisma 7’s next error is usually this one:
PrismaClientInitializationError: PrismaClient was instantiated without any options. A driver adapter is required to connect to your database.
Prisma 7 needs a driver adapter. For Postgres:
import { PrismaPg } from '@prisma/adapter-pg';
const prisma = new PrismaClient({ adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL! }) });What didn’t work
How this was tested
One small project (a User model, the prisma-client-js generator, a script that does new PrismaClient()) installed from the same lockfile on Windows 11 with npm 11.9.0, in PowerShell and Git Bash, and on Ubuntu 24.04 in WSL with npm 11.19.0 and npm 12.2.0. Prisma 6.19.3 for the main error, then 7.10.0 for the Prisma 7 messages, run as CommonJS, ESM and TypeScript (tsx). Every fix was checked from a clean node_modules. I didn’t test Docker, Vercel, pnpm or Yarn. A production install without dev dependencies (npm ci --omit=dev) didn’t reproduce the error on Linux, so it isn’t listed as a cause.
The code for every case above is public, so you can run it yourself: prisma6-noinit and prisma-noinit in nk-repro.
— N.K., end of entry No.049