Error: @prisma/client did not initialize yet.
Hello everybody!
I'm working on a small nextjs project and ran into this error, after entering my info and going to my dashboard page:
Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
export const client = globalThis.prisma || new PrismaClient()
I've tried running the command again, deleting node modules and installing everything again to no avail. Can anybody help out?
Solution:Jump to solution
I had a similar issue, and I think I solved it by setting up a separate Prisma client file that looks like this
```
import { PrismaClient } from "@prisma/client";
...
5 Replies
Hey @Mkiza 👋
When exactly are you getting this error? Does it happen when you try to run this locally? Or does it occur when your app is deployed?
If this happens on your deployed app, then is
prisma generate
command a part of your build script?Hey @Nurul (Prisma) this happens when I run my app locally. The command executes fine, but when I access dashboard pages I get the error
Okay, is your repository open source? If yes, can you share the repository link? It's difficult to predict what might be going wrong without looking at the code.
Solution
I had a similar issue, and I think I solved it by setting up a separate Prisma client file that looks like this
Then I just
import prisma from @/lib/prisma.ts
wherever I want to use the client.Reed thank you so much I tried this and it worked!:heart:
Sorry for not getting back Nurul, I tried Reeds suggestion and that did it for me! :starstruck: