我正在使用Next.js、Prisma和Nexus (nexus plugin- Prisma ),并且一直在尝试生成一个Prisma客户端,但没有效果。每当我运行npx prisma generate时,我都会得到以下错误:
TypeError: outputDir.endsWith is not a function
at getDotPrismaDir (...)
at generateClient (...)以下是我的依赖项:
"dependencies": {
"@prisma/client": "^2.19.0",
"apollo-server-micro": "^2.22.2",
"graphql": "^15.5.0",
"next": "10.1.3",
"nexus": "^1.0.0",
"nexus-plugin-prisma": "^0.33.0",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"@types/react": "^17.0.3",
"prisma": "^2.20.1",
"typescript": "^4.2.3"
}
}我一直在按照Prisma CLI的建议执行以下步骤(到步骤3):
Next steps:
1. Set the DATABASE_URL in the .env file to point to your existing database. If your database has no tables yet, read https://pris.ly/d/getting-started
2. Set the provider of the datasource block in schema.prisma to match your database: postgresql, mysql or sqlite.
3. Run prisma db pull to turn your database schema into a Prisma data model.
4. Run prisma generate to install Prisma Client. You can then start querying your database.这里发生了什么事?
发布于 2021-04-06 17:45:19
将@prisma/client和prisma更新到最新版本,即2.20.1应该可以解决此问题。
发布于 2021-04-06 17:48:25
事实证明,prisma的版本需要与nexus-plugin-prisma提供的@prisma/client版本相同。将prisma更改为2.19.x并生成客户端成功了!
注意:你也不需要单独安装@prisma/client,因为它是插件附带的。
https://stackoverflow.com/questions/66966032
复制相似问题