prisma: 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.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 35 (4 by maintainers)

Most upvoted comments

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

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

I used this

npx prisma generate --no-engine

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.

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

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!

I’m using vercel edge and “npx prisma generate --no-engine” still not worked

npx prisma generate --no-engine

this worked for me

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

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.

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

I am getting this error in a Turborepo setup.