P
Prisma2d ago
IPEXA

Error

⨯ TypeError: Cannot read properties of undefined (reading '__internal') at prismaClientSingleton (webpack-internal:///(rsc)/./src/lib/prisma.ts:9:12) at eval (webpack-internal:///(rsc)/./src/lib/prisma.ts:11:43) at <unknown> (rsc)/./src/lib/prisma.ts (/Users/nicolaeser/Documents/Development/PROVID/website/.next/dev/server/app/[locale]/(app)/app/page.js:239:1) at eval (webpack-internal:///(rsc)/./src/lib/auth.ts:11:69) at <unknown> (rsc)/./src/lib/auth.ts (/Users/nicolaeser/Documents/Development/PROVID/website/.next/dev/server/app/[locale]/(app)/app/page.js:228:1) at eval (webpack-internal:///(rsc)/./src/app/[locale]/(app)/layout.tsx:9:67) at <unknown> (rsc)/./src/app/[locale]/(app)/layout.tsx (/Users/nicolaeser/Documents/Development/PROVID/website/.next/dev/server/app/[locale]/(app)/app/page.js:151:1) { type: 'TypeError', page: '/de/app' }
2 Replies
Prisma AI Help
You selected the bot's instantaneous insights. Let me compile your answer right away! That TypeError: Cannot read properties of undefined (reading '__internal') happens when Prisma Client v7 is instantiated in a way that doesn’t match its new requirements, especially in ESM / Next.js setups. [Prisma 7 ESM bug] From the linked issue and comments: 1. Prisma 7 requires an adapter (Rust‑free client)
With the default (Rust‑free) engine, new PrismaClient() without options is no longer valid – you must pass either a driver adapter or accelerateUrl. [Prisma 7 breaking changes; constructor change] Example for PostgreSQL with @prisma/adapter-pg (pattern only, adapt paths/env to your app):
import { PrismaClient } from '@prisma/client';
import { PrismaPg } from '@prisma/adapter-pg';

const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL! });

const prisma = new PrismaClient({ adapter });
export default prisma;

import { PrismaClient } from '@prisma/client';
import { PrismaPg } from '@prisma/adapter-pg';

const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL! });

const prisma = new PrismaClient({ adapter });
export default prisma;

2. If you’re using the singleton pattern, the inner call must pass the adapter too:
const prismaClientSingleton = () =>
new PrismaClient({ adapter });

const prisma = globalThis.prisma ?? prismaClientSingleton();
if (process.env.NODE_ENV !== 'production') globalThis.prisma = prisma;

export default prisma;

const prismaClientSingleton = () =>
new PrismaClient({ adapter });

const prisma = globalThis.prisma ?? prismaClientSingleton();
if (process.env.NODE_ENV !== 'production') globalThis.prisma = prisma;

export default prisma;

3. ESM/CJS workaround (optional)
Some users in pure ESM / NestJS resolved this specific __internal crash by forcing the client to generate as CommonJS:
generator client {
provider = "prisma-client"
moduleFormat = "cjs"
}

generator client {
provider = "prisma-client"
moduleFormat = "cjs"
}

Then run npx prisma generate. [ESM workaround] If you’ve already added an adapter and still see __internal, that may be the Prisma 7 bug mentioned in the issue; in that case, the moduleFormat = "cjs" workaround is the documented fix in the sources. [ESM work around]
IPEXA
IPEXAOP2d ago
how to keep it generated in @prisma/client

Did you find this page helpful?