-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
I have been trying to use Prisma ORM v7 with NestJS but have encountered some issues:
Prisma ORM now ships as an ES module and requires the following changes:
Addition of "type": "module" in package.json:
{
"type": "module",
"scripts": {...},
}
Without this, the following error is observed when attempting to install and use Prisma with Nestjs as per the NestJS docs:
ReferenceError: exports is not defined in ES module scope
However, adding that configuration requires all imports to explicitly end with .js or .ts, which is not the default in Nestjs.
The Upgrade to Prisma ORM 7 also requires these configurations in tsconfig.json:
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "node",
"target": "ES2023",
"strict": true,
"esModuleInterop": true
}
}
However, adding these configurations gives the following error:
Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'.ts
Disabling resolvePackageJsonExports gives:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/path/dist/src/app.module' imported from /path/dist/src/main.js
I am unsure how to proceed, any oversights or identifications of knowledge gaps would be much appreciated, thank you!