环境变量参考
本文档描述了不同的环境变量及其用例。
¥This document describes different environment variables and their use cases.
Prisma 客户端
¥Prisma Client
DEBUG
DEBUG
用于在 Prisma Client 中启用调试输出。
¥DEBUG
is used to enable debugging output in Prisma Client.
设置 Prisma 客户端级别调试输出的示例:
¥Example setting Prisma Client level debugging output:
# enable only `prisma:client`-level debugging output
export DEBUG="prisma:client"
请参阅 调试 了解更多信息。
¥See Debugging for more information.
NO_COLOR
NO_COLOR
如果 truthy 将激活错误格式的 colorless
设置并从错误消息中去除颜色。
¥NO_COLOR
if truthy will activate the colorless
setting for error formatting and strip colors from error messages.
请参阅 通过环境变量格式化 了解更多信息。
¥See Formatting via environment variables for more information.
Prisma 工作室
¥Prisma Studio
BROWSER
BROWSER
是 Prisma Studio 强制在哪个浏览器中打开它,如果不设置它将在默认浏览器中打开。
¥BROWSER
is for Prisma Studio to force which browser it should be open in, if not set it will open in the default browser.
BROWSER=firefox prisma studio --port 5555
或者,你也可以在从 CLI 启动 Studio 时进行设置:
¥Alternatively you can set this when starting Studio from the CLI as well:
prisma studio --browser firefox
有关详细信息,请参阅 工作室 文档。
¥See Studio documentation for more information.
Prisma CLI
PRISMA_HIDE_PREVIEW_FLAG_WARNINGS
PRISMA_HIDE_PREVIEW_FLAG_WARNINGS
隐藏了警告消息,指出可以删除预览功能标志。这是一个真值。
¥PRISMA_HIDE_PREVIEW_FLAG_WARNINGS
hides the warning message that states that a preview feature flag can be removed. It is a truthy value.
PRISMA_HIDE_UPDATE_MESSAGE
PRISMA_HIDE_UPDATE_MESSAGE
用于隐藏当有较新的 Prisma CLI 版本可用时显示的更新通知消息。这是一个真值。
¥PRISMA_HIDE_UPDATE_MESSAGE
is used to hide the update notification message that is shown when a newer Prisma CLI version is available. It's a truthy value.
PRISMA_GENERATE_SKIP_AUTOINSTALL
如果在使用 prisma generate
命令时在 Prisma 架构中定义了 prisma-client-js
生成器,则可以将 PRISMA_GENERATE_SKIP_AUTOINSTALL
设置为真值以跳过 prisma
CLI 和 @prisma/client
依赖(如果缺少)的自动安装。
¥PRISMA_GENERATE_SKIP_AUTOINSTALL
can be set to a truthy value to skip the auto-install of prisma
CLI and @prisma/client
dependencies (if they are missing), if the prisma-client-js
generator is defined in the Prisma Schema, when using the prisma generate
command.
PRISMA_SKIP_POSTINSTALL_GENERATE
PRISMA_SKIP_POSTINSTALL_GENERATE
可以设置为真值,以在包管理器触发 postinstall
钩子时跳过 Prisma 客户端的自动生成。当安装包或其版本更新时,会触发 @prisma/client
包的 postinstall
钩子。
¥PRISMA_SKIP_POSTINSTALL_GENERATE
can be set to a truthy value to skip the auto-generation of Prisma Client when its postinstall
hook is triggered by a package manager. The postinstall
hook of the @prisma/client
package is triggered when the package is installed, or its version is updated.
PRISMA_DISABLE_WARNINGS
禁用 logger.warn
生成的所有 CLI 警告。
¥Disables all CLI warnings generated by logger.warn
.
PRISMA_GENERATE_NO_ENGINE
该环境变量自 5.2.0
版本起可用
¥This environment variable is available since version 5.2.0
PRISMA_GENERATE_NO_ENGINE
可以设置为真值以生成不包含 查询引擎 的 Prisma 客户端,以便在与 Prisma 加速 配对时减少部署的应用大小。
¥PRISMA_GENERATE_NO_ENGINE
can be set to a truthy value to generate a Prisma Client without an included query engine in order to reduce deployed application size when paired with Prisma Accelerate.
PRISMA_SCHEMA_DISABLE_ADVISORY_LOCK
该环境变量自 5.3.0
版本起可用
¥This environment variable is available since version 5.3.0
PRISMA_SCHEMA_DISABLE_ADVISORY_LOCK
可以设置为真值以禁用 Prisma Migrate 使用的 咨询锁定。这可能是需要的,具体取决于数据库配置,例如 Percona-XtraDB-Cluster 或 MariaDB Galera Cluster。
¥PRISMA_SCHEMA_DISABLE_ADVISORY_LOCK
can be set to a truthy value to disable the advisory locking used by Prisma Migrate. This might be needed, depending on the database configuration, for example, for a Percona-XtraDB-Cluster or MariaDB Galera Cluster.
代理环境变量
¥Proxy environment variables
Prisma CLI 支持自定义 HTTP(S) 代理来下载 Prisma 引擎。当在公司防火墙后面工作时,这些可能会很有帮助。请参阅 对 CLI 使用 HTTP 代理 了解更多信息。
¥The Prisma CLI supports custom HTTP(S) proxies to download the Prisma engines. These can be helpful to use when working behind a corporate firewall. See Using a HTTP proxy for the CLI for more information.
NO_PROXY
NO_PROXY
是不需要代理的主机名或 IP 地址的逗号分隔列表。
¥NO_PROXY
is a comma-separated list of hostnames or IP addresses that do not require a proxy.
NO_PROXY=myhostname.com,10.11.12.0/16,172.30.0.0/16
HTTP_PROXY
HTTP_PROXY
设置为代理服务器的主机名或 IP 地址。
¥HTTP_PROXY
is set with the hostname or IP address of a proxy server.
HTTP_PROXY=http://proxy.example.com
HTTPS_PROXY
HTTPS_PROXY
设置为代理服务器的主机名或 IP 地址。
¥HTTPS_PROXY
is set with the hostname or IP address of a proxy server.
HTTPS_PROXY=https://proxy.example.com
引擎环境变量
¥Engine environment variables
配置查询引擎类型
¥Configuring Query Engine Type
PRISMA_CLI_QUERY_ENGINE_TYPE
PRISMA_CLI_QUERY_ENGINE_TYPE
用于 定义 Prisma CLI 下载和使用的查询引擎类型。默认为 library
,但可以设置为 binary
:
¥PRISMA_CLI_QUERY_ENGINE_TYPE
is used to define the query engine type Prisma CLI downloads and uses. Defaults to library
, but can be set to binary
:
PRISMA_CLI_QUERY_ENGINE_TYPE=binary
PRISMA_CLIENT_ENGINE_TYPE
PRISMA_CLIENT_ENGINE_TYPE
用于 定义 Prisma 客户端下载和使用的查询引擎类型。默认为 library
,但可以设置为 binary
:
¥PRISMA_CLIENT_ENGINE_TYPE
is used to define the query engine type Prisma Client downloads and uses. Defaults to library
, but can be set to binary
:
PRISMA_CLIENT_ENGINE_TYPE=binary
注意:设置此变量后,你需要生成 Prisma 客户端,以使配置生效并下载库。否则,Prisma 客户端将缺少适当的查询引擎库,你将必须使用 PRISMA_QUERY_ENGINE_LIBRARY
定义它们的位置。
¥Note: You need to generate your Prisma Client after setting this variable for the configuration to take effect and the libraries to be downloaded. Otherwise, Prisma Client will be missing the appropriate query engine library and you will have to define their location using PRISMA_QUERY_ENGINE_LIBRARY
.
它是 generator
块的 engineType
属性 的等效环境变量,使你能够在 Prisma 架构中定义相同的设置。
¥It is the environment variable equivalent for the engineType
property of the generator
block which enables you to define the same setting in your Prisma Schema.
下载引擎
¥Downloading Engines
PRISMA_ENGINES_MIRROR
PRISMA_ENGINES_MIRROR
可用于指定自定义 CDN(或服务器)端点来下载 CLI/客户端的引擎文件。默认值为 https://binaries.prisma.sh
,Prisma 在此托管引擎文件。
¥PRISMA_ENGINES_MIRROR
can be used to specify a custom CDN (or server) endpoint to download the engines files for the CLI/Client. The default value is https://binaries.prisma.sh
, where Prisma hosts the engine files.
PRISMA_ENGINES_MIRROR=https://example.org/custom-engines/
有关如何使用此环境变量的概念概述,请参阅 Prisma 引擎。
¥See Prisma engines for a conceptual overview of how to use this environment variable.
注意:该环境变量过去以 PRISMA_BINARIES_MIRROR
形式提供,但在 Prisma ORM 3.0.1 中已弃用。不鼓励再使用,将来会被删除。
¥Note: This environment variable used to be available as PRISMA_BINARIES_MIRROR
, which was deprecated in Prisma ORM 3.0.1. It is discouraged to use anymore and will be removed in the future.
PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING
该环境变量自 4.16.0
版本起可用
¥This environment variable is available since version 4.16.0
PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING
可以设置为真值,以忽略下载和验证 Prisma ORM 引擎完整性(通过校验和文件)的问题。当部署到无法下载校验和文件的离线系统环境时,这特别有用。
¥PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING
can be can be set to a truthy value to ignore problems around downloading & verifying the integrity (via a checksum file) of the Prisma ORM engines.
This is particularly useful when deploying to an offline system environment where the checksum file cannot be downloaded.
PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING=1
注意:我们可能会在未来版本中更改整体下载行为,以便在离线环境情况下不再需要此环境变量。
¥Note: we might change the overall download behavior in a future release in a way that this environment variable will not be needed anymore in a offline environment case.
自定义引擎文件位置
¥Custom engine file locations
默认情况下,所有引擎文件都会在安装 Prisma CLI 时下载,在生成 Prisma 客户端时复制,并放入已知位置。然而,在某些情况下,你可能希望使用来自自定义位置的自定义引擎文件:
¥By default, all engine files are downloaded when you install Prisma CLI, copied when generating Prisma Client, and put into known locations. There are however situations where you may want to use a custom engine file from custom locations:
PRISMA_QUERY_ENGINE_BINARY
PRISMA_QUERY_ENGINE_BINARY
用于为你自己的查询引擎二进制文件设置自定义位置。
¥PRISMA_QUERY_ENGINE_BINARY
is used to set a custom location for your own query engine binary.
PRISMA_QUERY_ENGINE_BINARY=custom/query-engine-<target>
# Example: ./prisma/binaries/query-engine-linux-arm64-openssl-1.0.x
对于 Prisma CLI,它允许你定义要使用的查询引擎文件。对于 Prisma 客户端,在构建时(prisma generate
期间),它定义将从何处将查询引擎文件复制到 Prisma 客户端。在运行时(使用生成的客户端时),它可用于定义要使用的特定查询引擎文件,而不是包含的文件。
¥For Prisma CLI it allows you to define the query engine file to be used.\ For Prisma Client, on build time (during prisma generate
), it defines where the query engine file will be copied from into Prisma Client. At run time (when using the generated Client) it can be used to define the specific query engine file to be used instead of the included one.
注意:仅当 CLI 或客户端的引擎类型设置为 binary
时,此操作才会生效。如果引擎类型为 library
(默认),请改用 PRISMA_QUERY_ENGINE_LIBARY。
¥Note: This can only have an effect if the engine type of CLI or Client are set to binary
. If the engine type is library
(the default), use PRISMA_QUERY_ENGINE_LIBARY instead.
PRISMA_QUERY_ENGINE_LIBRARY
PRISMA_QUERY_ENGINE_LIBRARY
用于为你自己的查询引擎库设置自定义位置。
¥PRISMA_QUERY_ENGINE_LIBRARY
is used to set a custom location for your own query engine library.
PRISMA_QUERY_ENGINE_LIBRARY=custom/libquery_engine-<target>.so.node
# Example: ./prisma/binaries/libquery_engine-linux-arm64-openssl-1.0.x.so.node
对于 Prisma CLI,它允许你定义要使用的查询引擎文件。对于 Prisma 客户端,在构建时(prisma generate
期间),它定义将从何处将查询引擎文件复制到 Prisma 客户端。在运行时(使用生成的客户端时),它可用于定义要使用的特定查询引擎文件,而不是包含的文件。
¥For Prisma CLI it allows you to define the query engine file to be used.\ For Prisma Client, on build time (during prisma generate
), it defines where the query engine file will be copied from into Prisma Client. At run time (when using the generated Client) it can be used to define the specific query engine file to be used instead of the included one.
注意:仅当 CLI 或客户端的引擎类型设置为 library
(默认)时,此选项才会生效
¥Note: This can only have an effect if the engine type of CLI or Client are set to library
(the default)
PRISMA_SCHEMA_ENGINE_BINARY
PRISMA_SCHEMA_ENGINE_BINARY
用于为架构引擎二进制文件设置自定义位置。
¥PRISMA_SCHEMA_ENGINE_BINARY
is used to set a custom location for your Schema engine binary.
PRISMA_SCHEMA_ENGINE_BINARY=custom/my-schema-engine-unix
PRISMA_MIGRATION_ENGINE_BINARY
PRISMA_MIGRATION_ENGINE_BINARY
用于为你自己的迁移引擎二进制文件设置自定义位置。
¥PRISMA_MIGRATION_ENGINE_BINARY
is used to set a custom location for your own migration engine binary.
PRISMA_MIGRATION_ENGINE_BINARY=custom/my-migration-engine-unix
PRISMA_INTROSPECTION_ENGINE_BINARY
PRISMA_INTROSPECTION_ENGINE_BINARY
用于为你自己的内省引擎二进制文件设置自定义位置。
¥PRISMA_INTROSPECTION_ENGINE_BINARY
is used to set a custom location for your own introspection engine binary.
PRISMA_INTROSPECTION_ENGINE_BINARY=custom/my-introspection-engine-unix
PRISMA_FMT_BINARY
此功能已在 Prisma CLI 版本 4.10.0 中删除。它仅适用于早期版本。
¥This functionality has been removed in Prisma CLI version 4.10.0. It only works in earlier versions.
PRISMA_FMT_BINARY
用于为你自己的格式引擎二进制文件设置自定义位置。
¥PRISMA_FMT_BINARY
is used to set a custom location for your own format engine binary.
PRISMA_FMT_BINARY=custom/my-custom-format-engine-unix
CLI 二进制目标
¥CLI Binary Targets
PRISMA_CLI_BINARY_TARGETS
PRISMA_CLI_BINARY_TARGETS
可用于指定 Prisma CLI 在安装过程中下载的一个或多个二进制目标(因此必须在 Prisma CLI 的 npm install
期间提供,并且不会影响 Prisma CLI 或 Prisma Client 的运行时)。
¥PRISMA_CLI_BINARY_TARGETS
can be used to specify one or more binary targets that Prisma CLI will download during installation (so it must be provided during npm install
of Prisma CLI and does not affect runtime of Prisma CLI or Prisma Client).
如果你 1) 通过上传包含依赖的本地项目部署到特定平台,并且 2) 你的本地环境与目标不同(例如带有 Node.js 20+ 的 AWS Lambda 是 rhel-openssl-3.0.x
,并且你的本地环境),请使用 PRISMA_CLI_BINARY_TARGETS
可能是 macOS arm64 darwin-arm64
)。使用 PRISMA_CLI_BINARY_TARGETS
环境变量可确保目标引擎文件也被下载。
¥Use PRISMA_CLI_BINARY_TARGETS
if you 1) deploy to a specific platform via an upload of a local project that includes dependencies, and 2) your local environment is different from the target (e.g. AWS Lambda with Node.js 20+ is rhel-openssl-3.0.x
, and your local environment might be macOS arm64 darwin-arm64
). Using the PRISMA_CLI_BINARY_TARGETS
environment variable ensures that the target engine files are also downloaded.
PRISMA_CLI_BINARY_TARGETS=darwin-arm64,rhel-openssl-3.0.x npm install
这是 generator
块的 binaryTargets
属性 的 Prisma CLI 等效项,使你能够为 Prisma Client 定义相同的设置。
¥This is the Prisma CLI equivalent for the binaryTargets
property of the generator
block, which enables you to define the same setting for Prisma Client.
注意:对于 20 之前的 Node.js 版本,openssl 版本为 1.0.x,而不是 3.0.x。这在 AWS Lambda 部署中最为明显,其中二进制目标是
rhel-openssl-1.0.x
而不是rhel-openssl-3.0.x
。¥Note: For Node.js versions earlier than 20, the openssl version was 1.0.x instead of 3.0.x. This is most obvious in AWS Lambda deployments, where the binary target would be
rhel-openssl-1.0.x
instead ofrhel-openssl-3.0.x
.