P
Prisma2d ago
skidy

why do i get this build error after updating to prisma 7?

Failed to compile.

./src/generated/prisma/client.ts
Module not found: Can't resolve './internal/class.js'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./src/app/api/threads/route.ts

./src/generated/prisma/client.ts
Module not found: Can't resolve './internal/prismaNamespace.js'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./src/app/api/threads/route.ts

./src/generated/prisma/client.ts
Module not found: Can't resolve './enums.js'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./src/app/api/threads/route.ts


> Build failed because of webpack errors
Failed to compile.

./src/generated/prisma/client.ts
Module not found: Can't resolve './internal/class.js'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./src/app/api/threads/route.ts

./src/generated/prisma/client.ts
Module not found: Can't resolve './internal/prismaNamespace.js'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./src/app/api/threads/route.ts

./src/generated/prisma/client.ts
Module not found: Can't resolve './enums.js'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./src/app/api/threads/route.ts


> Build failed because of webpack errors
{
"compilerOptions": {
"target": "ES2023",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
{
"compilerOptions": {
"target": "ES2023",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
3 Replies
Prisma AI Help
You selected the bot's instantaneous insights. Let me compile your answer right away!
Prisma AI Help
You’re hitting a known Prisma 6/7 + Next.js/Webpack issue: the new provider = "prisma-client" generator emits TypeScript files (client.ts, internal/class.ts, enums.ts, internal/prismaNamespace.ts) but the generated client.ts imports them as ESM .js files:
import * as $Enums from "./enums.js";
import * as $Class from "./internal/class.js";
import * as Prisma from "./internal/prismaNamespace.js";
export * as $Enums from "./enums.js";
import * as $Enums from "./enums.js";
import * as $Class from "./internal/class.js";
import * as Prisma from "./internal/prismaNamespace.js";
export * as $Enums from "./enums.js";
Since only .ts files exist at that point, Webpack (used by Next.js) can’t resolve these .js imports and you get exactly the Can't resolve './internal/class.js' / './internal/prismaNamespace.js' / './enums.js' errors. [Prisma 7 Webpack; Generated imports .js] This is a Prisma bug/regression with the TypeScript-output client and custom output paths / bundlers like Webpack/Next.js. [Incorrect imports; NextJS - Prisma] From the sources, there are only workarounds, no clean built‑in fix yet: 1. Use CommonJS client instead of the TS ESM-style client In schema.prisma:
generator client {
provider = "prisma-client"
moduleFormat = "cjs"
// optionally remove custom output or keep what works for you
}

generator client {
provider = "prisma-client"
moduleFormat = "cjs"
// optionally remove custom output or keep what works for you
}

Then re‑generate:
npx prisma generate

npx prisma generate

This avoids the problematic .js imports in .ts files. [Prisma 7 ESM fix] 2. (Less ideal, per issues) Add a bundler step that compiles those TS files to JS and import from the compiled location (e.g. via tsc or Webpack config alias), but this is explicitly noted as clunky in the reports and can still fail in Next.js. [Client.js workaround; [Next.js Webpack fail](<https://github.com/prism
GitHub
Prism
Prism has 5 repositories available. Follow their code on GitHub.
Prisma AI Help
a/prisma/issues/28627>)] Given you’re on Next.js, the most reliable workaround from the shared issues is switching to moduleFormat = "cjs" for now and regenerating the client. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.

Did you find this page helpful?