Need Help
I am using prisma orm. Locally everything works fine but when i deploy my project to the vercel and test it returns this error. What is the issue and how to solve this? my project is in next js

8 Replies
You opted for speed from this bot. Let's conjure up an answer right now!
When deploying a Next.js project using Prisma to Vercel, it's common for things to work locally but fail in production. Based on the knowledge sources, here are the most frequent causes and solutions:
1. Prisma Client Not Generated in Production
Vercel caches dependencies, so Prisma's auto-generation may not run. You must ensure
Vercel does not use your local
If you customize the Prisma Client output path or use custom binary targets, you may need extra configuration for Vercel. For example, if you see errors about missing query engines or WASM files, you may need to adjust your
- Add
Vercel caches dependencies, so Prisma's auto-generation may not run. You must ensure
prisma generate
is executed during the build. Add this to your package.json
:
This ensures Prisma Client is generated both locally and on Vercel builds. Without this, you may see errors like @prisma/client did not initialize yet
or prisma is not defined
discussion 21558, discussion 22213, issue 9567.
2. Environment Variables Not Set CorrectlyVercel does not use your local
.env
file. You must set your DATABASE_URL
(and any other required env vars) in the Vercel dashboard under Project Settings > Environment Variables. If you see errors like Environment variable not found: DATABASE_URL
, this is likely the cause issue 27867, discussion 4848, issue 5636.
3. Prisma Client Output Path or Binary IssuesIf you customize the Prisma Client output path or use custom binary targets, you may need extra configuration for Vercel. For example, if you see errors about missing query engines or WASM files, you may need to adjust your
next.config.js
or use the @prisma/nextjs-monorepo-workaround-plugin
issue 26966, issue 27486.
Summary:- Add
"postinstall": "prisma generate"
to your package.json
.
- Set all required environment variables in
Vercel's dashboard.
- If using custom output or binary targets, follow Prisma's Next.js deployment guides and consider using the workaround plugin if needed.
If you still have issues, please provide the exact error message for more targeted help.
🤔 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.Hey!
What does your generator in schema.prisma file look like?
Did you include
rhel-openssl-3.0..x
?
i had same issue i used moved to rust free version and now it work
yes i include that and still not working
Bump here I'm having the same issue with nextjs and the latest node
@Nilak14 @Parwar Yassin have you guys confirmed the files are actually on the AWS server?
that is to say, if you can, please paste the contents of node_modules/.prisma/client of the AWS environment your code runs in
sorry i don't know what you mean exactly
i hosted in vercel
and by moving to rust free version and adding this "postinstall": "prisma generate --no-engine"
to the scripts of my prisma package it have been fixed
and this is what prisma said in there docs about that postinstall
Generate Prisma Client in a postinstall script in package.json
To ensure the generated Prisma Client library is available on your deployed Vercel project, you should add a postinstall script to the scripts section of your package.json file:
package.json
{
// ...
"scripts": {
// ...
"postinstall": "prisma generate --no-engine"
}
//
}
The --no-engine flag ensures that the query engine binary is kept out of the generated Prisma Client library. It's not needed when using Prisma Postgres.
Ok, I'm trying that.
I mean to say the folder wasn't being uploaded to my aws instance (vercell in your case). The actual generated files/folder weren't making it onto the server.
The no-engine thing didn't work.
The answer appears to be "Use a Next-based API to do all the Prisma, and call said API from the sst function"
ooo soory that was a note for deploying on vercel and also that was mention in the docs not aws , however my self also not deploy that sepicific app to vercel but i just did in order to test thing then self host again
sorry i really dont know about aws deployment