prisma: Accelerate: "Invalid client engine type, please use `library` or `binary`" on Edge
Bug description
https://www.prisma.io/docs/accelerate/local-development I tried to develop locally using this solution, but encountered errors.
How to reproduce
import { PrismaClient } from "@prisma/client/edge";
import { withAccelerate } from '@prisma/extension-accelerate';
const prismaClientSingleton = () => {
return new PrismaClient({
log: ["query", "info", "warn", "error"],
}).$extends(withAccelerate())
};
type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>;
const globalForPrisma = globalThis as unknown as {
edge_prisma: PrismaClientSingleton | undefined;
};
const prisma = globalForPrisma.edge_prisma ?? prismaClientSingleton();
export const EdgePrisma = prisma;
if (process.env.NODE_ENV !== "production") globalForPrisma.edge_prisma = prisma;
middleware.ts
import { PrismaAdapter } from "@auth/prisma-adapter";
import NextAuth from "next-auth";
import { AuthConfig } from "./auth.config";
import { EdgePrisma } from "./lib/prisma/edge";
const {auth} = NextAuth({
...AuthConfig,
adapter:PrismaAdapter(EdgePrisma)
})
export const middleware = auth
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - api (API routes)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
*/
'/((?!sql|_next/static|_next/image|favicon.ico).*)',
],
}
Expected behavior
how to ressolve?
Prisma information
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
// Optional for WebAuthn support
Authenticator Authenticator[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Account {
userId String
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([provider, providerAccountId])
}
model Session {
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model VerificationToken {
identifier String
token String
expires DateTime
@@id([identifier, token])
}
// Optional for WebAuthn support
model Authenticator {
credentialID String @unique
userId String
providerAccountId String
credentialPublicKey String
counter Int
credentialDeviceType String
credentialBackedUp Boolean
transports String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([userId, credentialID])
}
// Add your code using Prisma Client
Environment & setup
- OS:
- Database:
- Node.js version:
Prisma Version
prisma : 5.15.0
@prisma/client : 5.15.0
Computed binaryTarget : windows
Operating System : win32
Architecture : x64
Node.js : v19.0.0
Query Engine (Node-API) : libquery-engine 12e25d8d06f6ea5a0252864dd9a03b1bb51f3022 (at node_modules\.pnpm\@prisma+engines@5.15.0\node_modules\@prisma\engines\query_engine-windows.dll.node)
Schema Engine : schema-engine-cli 12e25d8d06f6ea5a0252864dd9a03b1bb51f3022 (at node_modules\.pnpm\@prisma+engines@5.15.0\node_modules\@prisma\engines\schema-engine-windows.exe)
Schema Wasm : @prisma/prisma-schema-wasm 5.15.0-29.12e25d8d06f6ea5a0252864dd9a03b1bb51f3022
Default Engines Hash : 12e25d8d06f6ea5a0252864dd9a03b1bb51f3022
Studio : 0.501.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 28 (8 by maintainers)
i’m getting same error in local
The Prisma code is pretty stable and used by hundreds of thousands of users - so I would suggest you look more into how you use Prisma Client and share that with us in a way we can properly reproduce and understand what you are doing.