process.loadEnvFile(path)
稳定性: 1.1 - 积极开发
¥Stability: 1.1 - Active development
-
path
<string> | <URL> | <Buffer> | <undefined> .默认值:'./.env'
¥
path
<string> | <URL> | <Buffer> | <undefined>. Default:'./.env'
将 .env
文件加载到 process.env
中。在 .env
文件中使用 NODE_OPTIONS
不会对 Node.js 产生任何影响。
¥Loads the .env
file into process.env
. Usage of NODE_OPTIONS
in the .env
file will not have any effect on Node.js.
const { loadEnvFile } = require('node:process');
loadEnvFile();
import { loadEnvFile } from 'node:process';
loadEnvFile();