-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Prisma 7: PrismaClient fails to instantiate in ESM environment (TypeError: __internal undefined) #28670
Description
When using Prisma 7 in a pure ESM environment ("type": "module"), the PrismaClient constructor throws two different errors depending on how it is invoked.
-
Calling new PrismaClient() (no arguments)
TypeError: Cannot read properties of undefined (reading '__internal')
at new t (node_modules/@prisma/client/src/runtime/getPrismaClient.ts:239:27) -
Calling new PrismaClient({}) (empty object)
PrismaClientConstructorValidationError: Using engine type "client" requires either "adapter" or "accelerateUrl" to be provided to PrismaClient constructor.
This behavior did not occur in Prisma 6.x, where instantiating the client with no arguments worked normally.
📦 Environment
Prisma Version: 7.0.0
Node.js: 22.21.1
Package Manager: pnpm 10.15.1
Project Type: ESM ("type": "module")
OS: Windows 10
TypeScript: 5.9.3
Runtime: tsx 4.20.6
🔁 Steps to Reproduce
Create a project with ESM enabled:
{
"type": "module"
}
Install Prisma 7:
pnpm add -D prisma@^7.0.0
pnpm add @prisma/client@^7.0.0
Use a minimal schema:
generator client {
provider = "prisma-client"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Test {
id String @id @default(uuid())
}
Generate the client:
pnpm prisma generate
Try to instantiate PrismaClient in an ESM .ts file:
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient(); // ❌ Error 1
// or
const prisma = new PrismaClient({}); // ❌ Error 2
✅ Expected Behavior
new PrismaClient() should work with no arguments and use the DATABASE_URL environment variable, just like in Prisma 6.x.
❌ Actual Behavior
new PrismaClient() → crashes with __internal undefined error.
new PrismaClient({}) → Prisma requires adapter or accelerateUrl, which shouldn't be mandatory for the default engine.
🛠️ Current Workaround
Downgrading to Prisma 6.x resolves the problem:
pnpm add -D prisma@^6.0.0
pnpm add @prisma/client@^6.0.0
Updated schema:
generator client {
provider = "prisma-client-js"
}