process.loadEnvFile(path)
-
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();