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: open
  • Created 9 months ago
  • Reactions: 3
  • Comments: 25 (3 by maintainers)

Most upvoted comments

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

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

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.

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

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