diff --git a/doc/api/process.md b/doc/api/process.md index a4296b6d974d94..f269e2961d14fe 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -2260,6 +2260,29 @@ process.kill(process.pid, 'SIGHUP'); When `SIGUSR1` is received by a Node.js process, Node.js will start the debugger. See [Signal Events][]. +## `process.loadEnvFile(path)` + + + +> Stability: 1.1 - Active development + +* `path` {string | URL | Buffer | undefined}. **Default:** `'./.env'` + +Loads the `.env` file into `process.env`. Usage of `NODE_OPTIONS` +in the `.env` file will not have any effect on Node.js. + +```cjs +const { loadEnvFile } = require('node:process'); +loadEnvFile(); +``` + +```mjs +import { loadEnvFile } from 'node:process'; +loadEnvFile(); +``` + ## `process.mainModule` + +* `content` {string} + +The raw contents of a `.env` file. + +* Returns: {Object} + +Given an example `.env` file: + +```cjs +const { parseEnv } = require('node:util'); + +parseEnv('HELLO=world\nHELLO=oh my\n'); +// Returns: { HELLO: 'oh my' } +``` + +```mjs +import { parseEnv } from 'node:util'; + +parseEnv('HELLO=world\nHELLO=oh my\n'); +// Returns: { HELLO: 'oh my' } +``` + ## `util.promisify(original)`