Skip to content
Nilay Kabariya

Entry No.047·Database·Updated ·5 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.

What changed on Nov 17, 2026: Ran every Prisma 6 case on clean GitHub Windows and Ubuntu runners: the Windows install leaves the placeholder there too, and on Windows approving the scripts on npm 12 does not fix it.

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

The fix that worked

Make generate part of every install:

"postinstall": "prisma generate"
Not it? Every cause, tested ↓

Tested on

prisma / @prisma/client
6.19.3 and 7.10.0
npm
11.9.0, 11.19.0, 12.2.0; 11.19.1 and 12.2.2 on GitHub Actions (November 10)
Node
24.14.0 (Windows), 24.21.0 (Ubuntu, WSL)
OS
Windows 11 Pro + Ubuntu 24.04

✓ Last re-run on GitHub Actions · see the run · all repros

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

It isn’t only my PC. On November 10 the same project and lockfile ran on clean GitHub Actions runners (Node 24.22.2, npm 11.19.1). On Ubuntu, npm ci generated the client and the app ran. On the Windows runner, npm ci left the placeholder and the app threw did not initialize yet; npx prisma generate then fixed it. See the run.

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` (or, from 8.0.0-rc.34, `prisma generate` is a Prisma 7 command and is not available in Prisma 8), 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.

On November 10, 2026 the Prisma 6 cases ran again on GitHub Actions, on Windows and Ubuntu runners with Node 24.22.2, npm 11.19.1 and npm 12.2.2: the plain install, --ignore-scripts, npm 12 with and without allowScripts, and the postinstall fix. See the run.

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

Useful? Pass it on:Post on XFollow @EmotionalMatter

Related entries

  1. No.046

    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"}]}}}

    DATABASE7 min
  2. No.093

    Fix: bigint Failed to load bindings, pure JS will be used

    bigint: Failed to load bindings, pure JS will be used. Why npm 12 shows it on every install, whether it matters, and how to get the native build back.

    > bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)

    FIXED3 minWindows
  3. No.072

    npm error code ENOENT, and spawn npx ENOENT on Windows

    Read the path line first. On Windows, spawn npx ENOENT has a twist: adding .cmd now fails with EINVAL. Four ENOENT causes reproduced, each with its fix.

    > npm error code ENOENT

    FIXED3 minWindows

tip: paste the exact error text