错误:获取配置:无法在 Prisma 和 nextjs 中建立与 query-engine-node-api 库的连接

我将 nextjs 新项目与 Prisma 和 supabase 数据库一起使用。我正在使用ubuntu。

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:    22.04
Codename:   jammy

当我在我的项目中运行 Prisma push 并生成命令时。我在使用 npm 和 yarn 时遇到了同样的错误。我运行所有 Prisma 命令。我从一个新的 supabase 数据库开始。

prisma migrate dev
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error: Get config: Unable to establish a connection to query-engine-node-api library

Prisma CLI Version : 3.15.2
 npx prisma db push
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error: Get config: Unable to establish a connection to query-engine-node-api library

Prisma CLI Version : 3.15.2

prisma/schema.prisma 文件

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
}

添加环境变量后。

DATABASE_URL="postgresql://postgres:EeVVG-password-wDiII@db.qpzh-url-opda.supabase.co:5432/postgres"

I do not find why I'm facing errors with Prisma and supabase. I'm deleting the `node_modules` folder and creating one more project. but the problem is not solved.
stack overflow Error: Get config: Unable to establish a connection to query-engine-node-api library in Prisma and nextjs
原文答案

答案:

作者头像

我遇到过同样的问题。检查您是否在沙盒终端中。就我而言,我的 anaconda 环境已打开,因此我无法启动迁移。打开一个没有任何环境或沙箱的新终端。此外,查看其他解决方案,我发现如果您的 nodejs 安装是使用 snap 完成的,那么也会发生此错误。尝试使用 apt 重新安装 nodejs。

作者头像

I have faced the same error.

Downgrading node from 18 to 16 solves this problem for me. I did't find better solution for this problem. Reference: prisma github comment. I don't recommend to downgrade though.

But prisma works normally on node 16 lts.