Skip to content

Prisma ORM v7 ships as an ES Module which is creating compatibility issues with NestJS #3350

@RareParsec

Description

@RareParsec

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions