Skip to main content

Prisma Postgres 问题排查

本指南将帮助你解决使用 Prisma Postgres 时的常见问题。

¥This guide helps resolve common issues when working with Prisma Postgres.

运行 prisma init 时无法识别 --db 选项

¥The --db option is not recognized when running prisma init

问题

¥Problem

运行以下命令失败,因为无法识别 --db 选项:

¥Running the following command fails because the --db option is not recognized:

npx prisma init --db

原因

¥Cause

这可能是由于 npx 缓存引起的。如果你之前运行过 npx prisma init,你的计算机可能正在使用过时的缓存版本,该版本无法识别 --db 标志,因为该标志是在 Prisma ORM 的更高版本中引入的。

¥This can occur due to npx caching. If you've previously run npx prisma init, your machine may be using an outdated cached version that doesn't recognize the --db flag because it was only introduced in a later version of Prisma ORM.

解决方案

¥Solution

明确运行 latest Prisma CLI 版本:

¥Explicitly run the latest Prisma CLI version:

npx prisma@latest init --db

这可确保你使用的是最新的 CLI,从而避免过时的命令语法问题。

¥This ensures that you're using the most up-to-date CLI, preventing issues with outdated command syntax.

警告:在生产环境中,我们建议使用 prisma generate --no-engine

¥Warning: In production, we recommend using prisma generate --no-engine

问题

¥Problem

你在日志中看到以下错误:

¥You're seeing the following error in your logs:

prisma:warn: In production, we recommend using 'prisma generate --no-engine'

原因

¥Cause

Prisma ORM 默认使用 查询引擎 二进制文件,该二进制文件作为 @prisma/client 包的一部分部署。但是,使用 Prisma Postgres 时,无需这样做。

¥Prisma ORM by default uses a query engine binary that's deployed as part of the @prisma/client package. However, with Prisma Postgres, this is not needed.

解决方案

¥Solution

要消除此警告并生成不包含查询引擎的 Prisma 客户端,你可以运行以下命令:

¥To remove this warning and generate Prisma Client without the query engine, you can run the following command:

npx prisma generate --no-engine

运行 prisma init --db 时工作区计划已达上限

¥Workspace plan limit reached when running prisma init --db

问题

¥Problem

运行以下命令时:

¥When running the command:

npx prisma@latest init --db

你可能会在日志中看到以下错误消息:

¥You may encounter the following error message in your logs:

Workspace plan limit reached for feature "Project".

原因

¥Cause

你的默认 workspace 项目限制已达到。

¥Your default workspace project limit has been reached.

解决方案

¥Solution

要解决此问题,请考虑以下选项:

¥To resolve this issue, consider the following options:

  • 配置一个不同的工作区作为你的默认工作区 - 一个具有可用于其他项目的容量的工作区。

    ¥Configure a different Workspace as your default—one that has available capacity for additional projects.

  • 从当前默认工作区中删除未使用的项目或数据库以释放空间。

    ¥Delete unused projects or databases from your current default Workspace to free up space.

  • 确保你已在 Prisma CLI 中登录到正确的账户。有关身份验证和账户管理的更多详细信息,请参阅 Prisma CLI 文档

    ¥Ensure that you are logged into the correct account in the Prisma CLI. For more details on authentication and account management, please refer to the Prisma CLI documentation.

  • 升级到套餐 支持在默认工作区中运行更多项目。

    ¥Upgrade to a plan that supports more projects in your default Workspace.

实现一个或多个这些解决方案应该可以帮助你解决计划限制问题。

¥Implementing one or more of these solutions should help you overcome the plan limit issue.