Skip to content
Nilay Kabariya

Entry No.049·Database··4 min read

Fix: @prisma/client did not initialize yet (Prisma 6 and 7)

The error says run prisma generate. Why it keeps coming back on Windows, npm 12 and CI, reproduced, plus the errors Prisma 7 throws instead.

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)
✓ Reproduced on Windows 11 Pro + Ubuntu 24.04

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
  1. The fix01
  2. On Windows, the install didn’t generate for me02
  3. npm ci --ignore-scripts (and CI templates that use it)03
  4. npm 12 blocks Prisma’s install script04
  5. npm i prisma gave you Prisma 805
  6. Prisma 7 throws different errors06
  7. What didn’t work07
  8. How this was tested08

@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 215ms

Then 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 ci printed ✔ Generated Prisma Client (v6.19.3) during the install, and the app ran.
  • On Windows 11 (npm 11.9.0), npm ci ran @prisma/client’s postinstall without any error, generated nothing, and the app threw did not initialize yet. It happened from PowerShell and from Git Bash, and running npm rebuild @prisma/client changed 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 generate

npm 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

Useful? Pass it on:Post on XFollow @EmotionalMatter

Related entries

  1. No.048

    prisma generate not working: "No command registered" (Prisma 8)

    npm now installs a Prisma 8 release candidate as prisma@latest. It has no generate, migrate dev or db push. Reproduced, with the fix for Docker and CI.

    > {"kind":"result","envelope":{"ok":false,"commandId":"","error":{"code":"CLI.UNKNOWN_COMMAND","severity":"error","summary":"No command registered for `generate`","nextActions":[{"kind":"run-command","label":"List every command","command":"prisma --help"}]}}}

    DATABASE4 min
  2. No.042

    Fix: "Could not locate the bindings file" in sqlite3

    sqlite3 or better-sqlite3 installed fine, then can't find its .node file. Four causes reproduced, how the Tried: paths tell them apart, and the fix for each.

    > Error: Could not locate the bindings file. Tried:

    FIXED3 min
  3. No.039

    npm 12 breaking changes, tested: what actually breaks

    The headline change, install scripts blocked by default, broke puppeteer, cypress, sqlite3 and Claude Code's npm package, and silently skipped lefthook's git hooks. esbuild, bcrypt, sharp and better-sqlite3 kept working. Every install reported success, and the only sign was a warning after the summary.

    TESTED5 min

Post card · Newsletter

Get the next fix in your inbox.

One short email when a new entry is published. No spam, never shared, and you can leave any time.

— Nilay

or follow by RSSor on X

By subscribing you agree to the privacy note. One click to leave.

tip: paste the exact error text