Repository navigation
Description
Bug description
If I'm trying to use Prisma Client with provider = "prisma-client" instead of provider = "prisma-client-js", I receive the following error:
path-to-project/dist/prisma/client/client.js:35
Object.defineProperty(exports, "__esModule", { value: true });
^
ReferenceError: exports is not defined in ES module scope
In my project I use CommonJS, not ESM. Contents of my tsconfig.json:
{
"compilerOptions": {
"strict": true,
"strictPropertyInitialization": false,
"module": "nodenext",
"moduleResolution": "nodenext",
"noImplicitOverride": true,
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"target": "esnext",
"lib": ["esnext"],
"pretty": true,
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"types": ["vitest/globals"],
"paths": {
"@prisma-definitions/*": ["prisma/*"],
"@api/*": ["src/api/*"],
"@shared/*": ["src/shared/*"]
}
}
}Possibly the reason is "moduleResolution": "nodenext", but I need dynamic imports in my project, so I cannot change it to something else
Severity
Not critical, I can change back to provider = "prisma-client-js"`, but still I would like to use the new version
Reproduction
Expected vs. Actual Behavior
Prisma Client with the provider = "prisma-client" works both for CommonJS and ESM
Frequency
Consistently reproducible
Does this occur in development or production?
Both development and production
Is this a regression?
I'm note sure, I just decided to use the new provider and faced the issue
Workaround
If I manually remove import.meta.url (a.k.a. ESM specific stuff) from the generated Prisma code, then it works
Prisma Schema & Queries
// Add relevant schema.prisma snippetgenerator client {
provider = "prisma-client"
previewFeatures = ["relationJoins", "driverAdapters", "metrics", "queryCompiler"]
output = "./client"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}// Add relevant Prisma Client queryPrisma Config
// Add your `prisma.config.ts`N/A
Logs & Debug Info
// Debug logs here
path-to-project/dist/prisma/client/client.js:35
Object.defineProperty(exports, "__esModule", { value: true });
^
ReferenceError: exports is not defined in ES module scope
Environment & Setup
- OS: MacOS
- Database: PostgreSQL
- Node.js version: 22.17.0
Prisma Version
// Prisma version output
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
prisma : 6.10.1
@prisma/client : 6.10.1
Computed binaryTarget : darwin-arm64
Operating System : darwin
Architecture : arm64
Node.js : v22.17.0
TypeScript : 5.8.3
Query Compiler : enabled
PSL : @prisma/prisma-schema-wasm 6.10.1-1.9b628578b3b7cae625e8c927178f15a170e74a9c
Schema Engine : schema-engine-cli 9b628578b3b7cae625e8c927178f15a170e74a9c (at node_modules/@prisma/engines/schema-engine-darwin-arm64)
Default Engines Hash : 9b628578b3b7cae625e8c927178f15a170e74a9c
Studio : 0.511.0
Preview Features : driverAdapters, metrics, queryCompiler, relationJoins
Activity
jkomyno commentedon Jul 1, 2025
Hey @pasha-vuiko,
Have you tried using
moduleFormat = "cjs"(see docs)?pasha-vuiko commentedon Jul 1, 2025
Heeey @jkomyno thank you so much it worked, I'm sorry, I did not know about the option
yassineejjoud commentedon Nov 5, 2025
omg thank you it worked
nndafnmain commentedon Nov 11, 2025
Thanks it works!!
zbouchlih commentedon Nov 26, 2025
thank you so much @jkomyno
fix: use prisma-client-js provider to fix E2E test failures
tongge666 commentedon Dec 15, 2025
Thanks it works!! Think you!!@jkomyno
Rayan-Allali commentedon Dec 29, 2025
thanks mate @jkomyno
aNazirov commentedon Mar 16, 2026
Thanks, it works.
moduleFormat = "cjs"was enough for my caseguilhermealves18 commentedon Mar 28, 2026
Thanks, work for me too
amiabl-programr commentedon Mar 30, 2026
It works for me too, thank you very much
ReactorboY commentedon Apr 12, 2026
It works, thank you very much.
NOTE: Please delete old generated PrismaClient and regenerate then it will work
Force CommonJS output for the Prisma client generator
shaishab316 commentedon Aug 29, 2026
Thank you,
[7:57:53 AM] File change detected. Starting incremental compilation...
[7:58:03 AM] Found 0 errors. Watching for file changes.
file:///C:/Users/Incognito/Projects/lumiphoto/dist/generated/prisma/client.js:38
Object.defineProperty(exports, "__esModule", { value: true });
^
ReferenceError: exports is not defined in ES module scope
at file:///C:/Users/Incognito/Projects/lumiphoto/dist/generated/prisma/client.js:38:23
at ModuleJobSync.runSync (node:internal/modules/esm/module_job:517:37)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:388:47)
at loadESMFromCJS (node:internal/modules/cjs/loader:1578:24)
at Module._compile (node:internal/modules/cjs/loader:1743:5)
at Object..js (node:internal/modules/cjs/loader:1893:10)
at Module.load (node:internal/modules/cjs/loader:1481:32)
at Module._load (node:internal/modules/cjs/loader:1300:12)
at TracingChannel.traceSync (node:diagnostics_channel:328:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
Node.js v24.12.0