prisma icon indicating copy to clipboard operation
prisma copied to clipboard

Confusing error message when trying to use engine type the client was not generated with

Open aqrln opened this issue 2 years ago • 29 comments

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.

aqrln avatar Oct 09 '23 14:10 aqrln

any updates on this? I'm using prisma with lucia in nextjs and this error popped up

WTanardi avatar Feb 28 '24 03:02 WTanardi

Can you clarify how that happens @WTanardi? We until now thought this was mostly an internal challenge when testing esoteric features on our side.

janpio avatar Feb 28 '24 13:02 janpio

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' }

firoz3130 avatar Feb 29 '24 05:02 firoz3130

Getting same error image

swapyshelke avatar Feb 29 '24 11:02 swapyshelke

You could try this solution:

  1. Set schema.prisma
generator client {
  provider   = "prisma-client-js"
  engineType = "library"
}
  1. change the import: import { PrismaClient } from "@prisma/client";

fwx5618177 avatar Mar 01 '24 17:03 fwx5618177

Same question for you @firoz3130 @swapyshelke @fwx5618177: Can you clarify how you end up in a situation where you get this error?

janpio avatar Mar 01 '24 18:03 janpio

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.

fwx5618177 avatar Mar 01 '24 18:03 fwx5618177

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.

firoz3130 avatar Mar 02 '24 19:03 firoz3130

@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')]

nckre avatar Mar 05 '24 13:03 nckre

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?

janpio avatar Mar 05 '24 14:03 janpio

I am getting this error in a Turborepo setup.

mattwoodco avatar Mar 21 '24 03:03 mattwoodco

@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.

frixaco avatar Mar 21 '24 10:03 frixaco

Also facing this error trying to connect to a remote DB from my local environment

helloiambguedes avatar Mar 21 '24 14:03 helloiambguedes

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?

EseCurtis avatar Mar 22 '24 07:03 EseCurtis

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

curiousmike avatar Mar 23 '24 20:03 curiousmike

I used this

npx prisma generate --no-engine

deeratra avatar Mar 25 '24 08:03 deeratra

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.

reggi avatar Mar 28 '24 05:03 reggi

PrismaClientValidationError: Invalid client engine type, please use libraryorbinary``

Parag2812 avatar Mar 31 '24 19:03 Parag2812

I have the same error

chriszlr avatar Apr 03 '24 13:04 chriszlr

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 avatar Apr 03 '24 15:04 leo-paz

@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.

adamchipperfield avatar Apr 10 '24 09:04 adamchipperfield

do we require a pool connection url of our db to use this? @leo-paz

harshdasila avatar Apr 11 '24 07:04 harshdasila

hey you can use this command it might be resolve your error

npx prisma generate --no-engine

InderKumhar0 avatar Apr 11 '24 12:04 InderKumhar0

@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

leo-paz avatar Apr 11 '24 16:04 leo-paz

You could try this solution:

  1. Set schema.prisma
generator client {
  provider   = "prisma-client-js"
  engineType = "library"
}
  1. change the import: import { PrismaClient } from "@prisma/client";

Thanks, it worked. Kudos!

rohan12345a avatar Apr 21 '24 10:04 rohan12345a

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:

Saurabh-001-S avatar May 02 '24 07:05 Saurabh-001-S

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.

issam-seghir avatar Jun 01 '24 14:06 issam-seghir

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

cyrus-za avatar Jun 14 '24 11:06 cyrus-za

npx prisma generate --no-engine

this worked for me

PS: I am not having any engine specified in the prisma.Schema file

Nivu789 avatar Jun 22 '24 05:06 Nivu789

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" }

dennis2828 avatar Jul 07 '24 08:07 dennis2828