【问题标题】:Cannot generate Prisma client, outputDir.endsWith is not a function无法生成 Prisma 客户端,outputDir.endsWith 不是函数
【发布时间】:2021-07-02 01:59:31
【问题描述】:

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

这是怎么回事?

【问题讨论】:

    标签: javascript typescript nexus prisma


    【解决方案1】:

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

    【讨论】:

    • 是的,版本不匹配是瓶颈,原来我必须降级prisma才能与nexus-plugin-prisma兼容!
    【解决方案2】:

    原来prisma 的版本需要与nexus-plugin-prisma 提供的@prisma/client 的版本相同。将prisma 更改为2.19.x 并生成客户端工作正常!

    注意:您也不需要单独安装@prisma/client,因为这是插件附带的。

    【讨论】:

    • 您使用的似乎是旧版本的nexus-plugin-prisma@prisma/client 不再捆绑在较新的版本中。
    • @Ryan 我用的是0.33.0,这不是几天前才发布的吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-10
    • 2012-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多