.env 文件


¥.env files

.env 文件(也称为 dotenv 文件)是定义环境变量的文件,Node.js 应用可以与这些环境变量进行交互(由 dotenv 包推广)。

¥.env files (also known as dotenv files) are files that define environment variables, which Node.js applications can then interact with (popularized by the dotenv package).

以下是基本 .env 文件内容的示例:

¥The following is an example of the content of a basic .env file:

MY_VAR_A = "my variable A"
MY_VAR_B = "my variable B" 

这种类型的文件用于各种不同的编程语言和平台,但目前尚无正式规范,因此 Node.js 定义了如下所述的自己的规范。

¥This type of file is used in various different programming languages and platforms but there is no formal specification for it, therefore Node.js defines its own specification described below.

.env 文件是一个包含键值对的文件,每对键值对由变量名、等号 (=) 和变量值表示。

¥A .env file is a file that contains key-value pairs, each pair is represented by a variable name followed by the equal sign (=) followed by a variable value.

此类文件的名称通常为 .env 或以 .env 开头(例如 .env.dev,其中 dev 表示特定的目标环境)。这是推荐的命名方案,但并非强制要求,dotenv 文件可以采用任意文件名。

¥The name of such files is usually .env or it starts with .env (like for example .env.dev where dev indicates a specific target environment). This is the recommended naming scheme but it is not mandatory and dotenv files can have any arbitrary file name.