P
Prisma•5mo ago
chr.yx

PrismaClientInitializationError on vercel

Error [PrismaClientInitializationError]: Invalid prisma.user.findFirst() invocation: Prisma Client could not locate the Query Engine for runtime "rhel-openssl-3.0.x". We detected that you are using Next.js, learn how to fix this: https://pris.ly/d/engine-not-found-nextjs. This is likely caused by a bundler that has not copied "libquery_engine-rhel-openssl-3.0.x.so.node" next to the resulting bundle. Ensure that "libquery_engine-rhel-openssl-3.0.x.so.node" has been copied next to the bundle or in "app/generated/prisma". We would appreciate if you could take the time to share some information with us. Please help us by answering a few questions: https://pris.ly/engine-not-found-bundler-investigation The following locations have been searched: /var/task/app/generated/prisma /var/task/.next/server /vercel/path0/app/generated/prisma /var/task/.prisma/client /tmp/prisma-engines at oj.handleRequestError (.next/server/chunks/131.js:114:8288) at oj.handleAndLogRequestError (.next/server/chunks/131.js:114:7049) at oj.request (.next/server/chunks/131.js:114:6756) at async s (.next/server/chunks/131.js:126:7629) at async Object.findOne (.next/server/chunks/697.js:85:66659) at async Object.findOne (.next/server/chunks/697.js:1:13740) at async (.next/server/chunks/697.js:85:71616) at async r (.next/server/chunks/697.js:95:176997) at async i.<computed> [as signInUsername] (.next/server/chunks/697.js:93:140754) { clientVersion: '6.11.1', errorCode: undefined }
Prisma
Prisma | Instant Postgres plus an ORM for simpler db workflows
Build, fortify, and grow your application easily with an intuitive data model, type-safety, automated migrations, connection pooling and caching.
GitHub
User questions: Engine not found (bundler) · prisma prisma · Disc...
Hi, you have been directed to this discussion because we want to learn more about your project setup. Thanks to your answers, we will be able to make better design decisions in the future. We&#39;d...
4 Replies
Prisma AI Help
Prisma AI Help•5mo ago
You opted for speed from this bot. Let's conjure up an answer right now! This error occurs because the Prisma Query Engine binary for the runtime "rhel-openssl-3.0.x" is not being found in your Vercel deployment. This is a common issue when deploying Prisma with Next.js (or other frameworks) to serverless environments like Vercel, especially when using custom output paths or monorepo setups. Why does this happen? - The Prisma Client is generated locally (often on macOS or another platform), but Vercel's serverless environment requires the Linux "rhel-openssl-3.0.x" binary. - The bundler (like Next.js or Turbopack) does not automatically copy the required engine binary (libquery_engine-rhel-openssl-3.0.x.so.node) to the deployment output directory. - If you set a custom output for the Prisma Client, Vercel may not know to include the engine binary in the serverless function bundle. How to fix: 1. Add the correct binaryTargets in your schema.prisma:
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "rhel-openssl-3.0.x"]
}

generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "rhel-openssl-3.0.x"]
}

Then run npx prisma generate before deploying. 2. If using a custom output or a monorepo, use the workaround plugin: Add the @prisma/nextjs-monorepo-workaround-plugin to your Next.js next.config.js or next.config.mjs:
import { PrismaPlugin } from '@prisma/nextjs-monorepo-workaround-plugin';

const nextConfig = {
webpack: (config, { isServer }) => {
if (isServer) {
config.plugins = [...config.plugins, new PrismaPlugin()];
}
return config;
},
};

export default nextConfig;

import { PrismaPlugin } from '@prisma/nextjs-monorepo-workaround-plugin';

const nextConfig = {
webpack: (config, { isServer }) => {
if (isServer) {
config.plugins = [...config.plugins, new PrismaPlugin()];
}
return config;
},
};

export default nextConfig;

This ensures the engine binary is copied to the correct location during the build process on Vercel. 3. Avoid custom output if possible: Some users report that not setting a custom output for the Prisma Client can avoid this issue entirely on Vercel, though this may not be feasible for all setups. For mor e details and user experiences, see this discussion and related issues. If you continue to have issues, check the Prisma documentation for Next.js deployment and consider using the workaround plugin as described above.
chr.yx
chr.yxOP•5mo ago
i have that
No description
Prisma AI Help
Prisma AI Help•5mo ago
🤔 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.
Nurul
Nurul•5mo ago
Hey! Did the bot response didn't help? Why did you have to add "node-api" engineType? That's not a valid attribute.

Did you find this page helpful?