NestJS - Prisma runtime error
i am getting the following runtime error
i tried reinstalling regenerating no matter what i do i still get the runtime error (prisma v7.0.0)
9 Replies
Skipping coffee for instant knowledge! Let's brew that AI answer now.
This is a known Prisma 7 issue that often appears in NestJS / ESM / monorepo setups as:
2. Ensuring no second client instance is created elsewhere, and
3. (Optionally) switching
you still see the same stack trace, then youβre likely hitting the unresolved Prisma 7 ESM bug and may need to temporarily stay on Prisma 6 per the reports. π€ 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.
TypeError: Cannot read properties of undefined (reading '__internal') [ESM bug issue; TS/runtime issue]
From the reports, there are three separate things to check:
---
1. Make sure you pass a driver adapter (Prisma 7 breaking change)
With engine type "client" you must now pass an adapter (or accelerateUrl) to PrismaClientβs constructor; otherwise youβll get constructor validation errors and in some cases the __internal crash. [ESM bug issue]
For Postgres in NestJS:
This pattern fixed the same error for another NestJS user. [ESM bug issue]
---
2. Avoid double-instantiation / mismatched client
If you also create a separate PrismaClient instance elsewhere and then extend PrismaClient in PrismaService, you can hit the same error. One user had:
and also:
which still crashed with __internal until they moved the adapter into the PrismaSe
rvice constructor (as above). [ESM bug issue]
Make sure you only construct the client in one place (typically the Nest service).
---
3. ESM-specific bug / workaround
There is an open bug where new PrismaClient() in pure ESM projects throws __internal even when env is correct. [ESM bug issue]
Temporary workarounds reported:
- Generate CJS client:
Then npx prisma generate. [ESM bug issue]
- Some users reverted to Prisma 6 until the bug is fixed. [TS/runtime issue]
---
If after:
1. Passing an adapter in your PrismaService constructor,2. Ensuring no second client instance is created elsewhere, and
3. (Optionally) switching
moduleFormat = "cjs"you still see the same stack trace, then youβre likely hitting the unresolved Prisma 7 ESM bug and may need to temporarily stay on Prisma 6 per the reports. π€ 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.
I tried the mentioned work around but it didnt work
What does your prisma service look like? Providing some context would be helpful. Maybe including the relevant file(s) in a gist?
just basic connection with database
Well there are a few things off, since you are on version 7.0.0 you need to handle things a bit differently π
You are not passing the adapter as the documentation suggests.
This is an important step, and breaking as of 7.0.0 (I think it may have been breaking since 6.15).
I actually have a blog post in which it should be well explained:
https://mgregersen.dk/upgrading-prisma-to-rust-free-client-in-nestjs/
Let me know if that works out for you.
But essentially you need to follow the documentation for 7.0, which you haven't, you are trying to implement the now-legacy rust based prisma client π
Martin Aarhus Gregersen
Martin Gregersen
Upgrading Prisma to Rust-free client in NestJS - Martin Gregersen
In this article Iβll quickly go over the steps I took to update Prisma to the new rust free implementation, that is now βGAβ as of Prisma version 6.16.0., as indicated by the recent blog on the topic: https://www.prisma.io/blog/rust-free-prisma-orm-is-ready-for-production Updating and configuring Prisma First things first, first we need to...
i see , thanks
No problem, let me know if you are still having issues, but you should be able to resolve your issues if you follow the examples the AI provided step by step π
i see i didnt see the first message sent by ai , i assumed it sent only 1 message and started from #3 , thanks for the help anyways
Hehe shit happens, hope it worked out. You are welcome! π