P
Prisma•2mo ago
ATL

Error "@prisma/client did not initialize yet." in Nuxt 4

So tl;dr of the issue is that when calling any API endpoint that uses Prisma I get following error
'@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.\n'
'@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.\n'
My project is using Nuxt 4 with new directory structure and Supabase. Prisma Studio is working normally so in some level the connection between prisma and the database is there. I have attached screenshot of my directory structure. Anything that looks odd there? I highlighted the prisma related stuff and the API endpoint using it that triggers the error. I have also attached a screenshot of the API Endpoint where PrismaClient is being imported and used. Also I should clarify that I have tried to run
npx prisma generate
npx prisma generate
That seemed to run successfully, yet the issue persists. Essentially it seems to me that in the get-for-user-new API endpoint the following line fails
const prisma = new PrismaClient();
const prisma = new PrismaClient();
Any help would be appreciated. Hope this is enough information.
No description
No description
4 Replies
Prisma AI Help
Prisma AI Help•2mo ago
You selected the carefully hand-crafted route. A dev artisan will respond soon. Meanwhile, the #ask-ai channel awaits if you're curious!
Nurul
Nurul•2mo ago
Hey! Are you using custom output path? Did you had a chance to look at this GitHub Discussion: https://github.com/prisma/prisma/discussions/23741
GitHub
Error: @prisma/client did not initialize yet. Please run "prisma ge...
Question i have added prisma generate in postinstall section in package.json i am getting this error in vercel. Error: @prisma/client did not initialize yet. Please run "prisma generate" ...
ATL
ATLOP•4w ago
Yes, this fixed it for me. In my schema.prisma file I had:
generator client {
provider = "prisma-client-js"
output = "../generated/prisma"
}
generator client {
provider = "prisma-client-js"
output = "../generated/prisma"
}
I just removed the output completely and now it works. I hadn't seen the issue thread that you showed me before. Somehow didn't come up while I was googling the issue. I had seen this one: https://github.com/prisma/prisma/issues/26991. However I was skeptical it was related to that as everything ran fine for me before the Nuxt 4 Directory structure change. Not sure if you know about the Nuxt specifically, but here's a bit of stupid question. Now when I ran generate I got following message:
āœ” Generated Prisma Client (v6.13.0) to .\node_modules\@prisma\client in 55ms
āœ” Generated Prisma Client (v6.13.0) to .\node_modules\@prisma\client in 55ms
Does this mean that the /generated folder in my project root is now unnecessary? (It only contained the /prisma folder in it. Once again huge thanks for help! šŸ™‚ Sorry it took so long to get back to you. Have had some busy days irl and just now had both time and non sleep deprived brain to get back to this issue.
GitHub
prisma/prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB - prisma/prisma
Nurul
Nurul•4w ago
If you have removed the output path then, the /generated folder is unnecessary šŸ‘

Did you find this page helpful?