loadEnvFile

abstract fun loadEnvFile()(source)
abstract fun loadEnvFile(path: String = definedExternally)(source)
abstract fun loadEnvFile(path: URL = definedExternally)(source)
abstract fun loadEnvFile(path: Buffer = definedExternally)(source)

Loads the environment configuration from a .env file into process.env. If the file is not found, error will be thrown.

To load a specific .env file by specifying its path, use the following code:

import { loadEnvFile } from 'node:process';

loadEnvFile('./development.env')

Since

v20.12.0

Parameters

path

The path to the .env file