Confusing error message when trying to use engine type the client was not generated with
When generating the client for the library engine, trying to use the binary engine like this:
PRISMA_CLIENT_ENGINE_TYPE=binary ts-node index.ts
produces the following error:
PrismaClientValidationError: Invalid client engine type, please use `library` or `binary`
It should only list the engine types this generated client supports.
any updates on this? I'm using prisma with lucia in nextjs and this error popped up
Can you clarify how that happens @WTanardi? We until now thought this was mostly an internal challenge when testing esoteric features on our side.
Yeah ,can anyone help on this? I am getting like this
⎔ Starting local server... X [ERROR] PrismaClientValidationError: Invalid client engine type, please use libraryor binary
{ clientVersion: '5.10.2' }
Getting same error
You could try this solution:
- Set
schema.prisma
generator client {
provider = "prisma-client-js"
engineType = "library"
}
- change the import:
import { PrismaClient } from "@prisma/client";
Same question for you @firoz3130 @swapyshelke @fwx5618177: Can you clarify how you end up in a situation where you get this error?
Same question for you @firoz3130 @swapyshelke @fwx5618177: Can you clarify how you end up in a situation where you get this error?
I have solved it.
Same question for you @firoz3130 @swapyshelke @fwx5618177: Can you clarify how you end up in a situation where you get this error?
I have a serverless backend project using cloudflare workers . I was testing some of the apis in my project using postman. So when I hit one of the apis , it was showing this error. It had a query to check if the user already exists in the db or not.
@janpio I ran into this error when trying to switch from the regular prisma client to edge (to enable running client w/ Vercel AI).
This is how I set up the client:
// lib/utils/db.ts
import { PrismaClient } from '@prisma/client/edge'
import { withAccelerate } from '@prisma/extension-accelerate'
export const db = new PrismaClient().$extends(withAccelerate())
And this is my generator:
generator client {
provider = "prisma-client-js"
}
Error:
⨯ PrismaClientValidationError: Invalid client engine type, please use `library` or `binary`
...
⨯ [Error: Invalid client engine type, please use `library` or `binary`] {
digest: '3407705892'
}
⨯ [TypeError: Cannot read properties of null (reading 'default')]
Can you elaborate a bit? Did you have a working project before? What steps did you take to modify it, which commands did you run along the way? Do you maybe have a way to create a reproduction that we can run ourselves?
I am getting this error in a Turborepo setup.
@janpio Here's a repro: https://github.com/frixaco/test-prisma-edge-nextjs
It's a simple Next.js (App Router) setup with Prisma. Error happens when using Edge client for me, running pnpm build.
Also facing this error trying to connect to a remote DB from my local environment
Same question for you @firoz3130 @swapyshelke @fwx5618177: Can you clarify how you end up in a situation where you get this error?
I have solved it.
How?
Same question for you @firoz3130 @swapyshelke @fwx5618177: Can you clarify how you end up in a situation where you get this error?
I have solved it.
How?
He showed above https://github.com/prisma/prisma/issues/21428#issuecomment-1973562337
I used this
npx prisma generate --no-engine
I'm getting this error using deno
➜ d-prisma deno run --allow-env ./lib/repl.ts
error: Uncaught (in promise) PrismaClientValidationError: Invalid client engine type, please use `library` or `binary`
at ms (file:///Users/thomasreggi/Desktop/d-prisma/generated/client/runtime/edge-esm.js:13:65)
at new t (file:///Users/thomasreggi/Desktop/d-prisma/generated/client/runtime/edge-esm.js:26:5761)
at file:///Users/thomasreggi/Desktop/d-prisma/lib/Session.ts:4:16
Update: I regenerated and it went away.
PrismaClientValidationError: Invalid client engine type, please use libraryorbinary``
I have the same error
I used this
npx prisma generate --no-engine
I modified my dev script like so and it worked
"dev": "npx prisma generate --no-engine && next dev",
@leo-paz I think that only works if you have a remote Accelerate connection. It doesn't work with a local database as described in the Prisma docs.
do we require a pool connection url of our db to use this? @leo-paz
hey you can use this command it might be resolve your error
npx prisma generate --no-engine
@harshdasila this is assuming you're using prisma accelerate like @adamchipperfield mentioned which requires a DATABASE_URL env (or whatever you named this) that points to your prisma accelerate instance and a DIRECT_DATABASE_URL which is a direct connection to your db
You could try this solution:
- Set
schema.prismagenerator client { provider = "prisma-client-js" engineType = "library" }
- change the import:
import { PrismaClient } from "@prisma/client";
Thanks, it worked. Kudos!
when i try this it showing this error X [ERROR] Error: PrismaClient is not configured to run in Cloudflare Workers. In order to run Prisma Client on edge runtime, either:
My problem is fixed by executing the command npx prisma generate --no-engine. and
generator client {
provider = "prisma-client-js"
engineType = "library"
}
Moreover, I realized that I had forgotten to replace the database URL with the new one provided by Prisma Accelerate.
Also running into this. Changing the engineType explicitly does not fix it for me.
This happens when I run in CI on nx cloud. I use PRISMA_GENERATE_NO_ENGINE="true" in my .env file locally and got the same configured on vercel environment, but in the CI if I do that, I'd need to run prisma accelerate, or have an accelerate url, despite the fact that I am mocking out my prisma for tests, so I can't do no-engine in CI as it needs the binary else prisma generate will error out with the url
npx prisma generate --no-engine
this worked for me
PS: I am not having any engine specified in the prisma.Schema file
I had the same problem while using Prisma Accelerator and i fixed it by adding engineType = "library" and also modifying the package.json prisma postinstall to "postinstall": "prisma generate --no-engine"
generator client { provider = "prisma-client-js" engineType = "library" }