.env 文件
【.env files】
.env 文件(也称为 dotenv 文件)是用于定义环境变量的文件,Node.js 应用可以与之交互(由 dotenv 包推广)。
以下是一个基本 .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.】