`过去几天一直在尝试在 deno 上设置 prisma(被开箱即用的 TS 所迷住),所以我将其全部设置并继续:
这是我的架构:
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["deno"]
output = "../generated/client"
engineType = "binary"
}
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
email String @unique
passwordHash String
sessions Session[]
recievedMessages Message[] @relation("RecievedMessages")
sentMessages Message[] @relation("SentMessages")
}
model Session {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ip String
userAgent String
token String @unique
userId Int
user User @relation(fields: [userId], references: [id])
}
model Message {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
content String
fromUserId Int
fromUser User @relation(fields: [fromUserId], references: [id], name: "RecievedMessages")
toUserId Int
toUser User @relation(fields: [toUserId], references: [id], name: "SentMessages")
}
这是我引用 prisma (prisma.ts) 的文件:
import { PrismaClient } from "../generated/client/deno/edge.ts";
export const prisma = new PrismaClient();
这些是我用于 prisma 的命令:
"tasks": {
"migrate": "deno run -A --unstable npm:prisma migrate dev --name init",
"generate": "deno run -A --unstable npm:prisma generate",
"dev": "deno run -A --env-file --watch src/server.ts"
},
这是运行“deno run dev”时弹出的错误
error: Uncaught (in promise) PrismaClientValidationError: Invalid client engine type, please use `library` or `binary`
at cs (file:// /server/generated/client/runtime/edge-esm.js:12:65)
at new t (file:// /server/generated/client/runtime/edge-esm.js:29:3661)
at file:// /server/db/prisma.ts:3:23
尝试了多种方法来解决这个问题:
您找到此错误的解决方案了吗?