首页 > 解决方案 > 无法生成 Prisma 客户端,outputDir.endsWith 不是函数

问题描述

我正在使用 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.

这里发生了什么?

标签: javascripttypescriptnexusprisma

解决方案


更新@prisma/clientprisma最新版本,即2.20.1应该可以解决这个问题。


推荐阅读