未捕获(承诺中)PrismaClientValidationError:客户端引擎类型无效

问题描述 投票:0回答:1

`过去几天一直在尝试在 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

尝试了多种方法来解决这个问题:

  • 在不同的目录中以不同的方式生成客户端
  • 尝试了不同的方法来设置架构
  • 搞乱了节点模块文件夹,但仍然不起作用
  • 尝试将 prisma.ts 中的导入更改为文档提到的方式(@prisma/client)
prisma deno
1个回答
0
投票

您找到此错误的解决方案了吗?

© www.soinside.com 2019 - 2024. All rights reserved.