process.loadEnvFile()
A Node.js function that loads a .env file into process.env from inside your program, doing what --env-file does on the command line.
In more detail
Called with no argument it reads ./.env. It is useful when the file to load depends on logic in the program.
Related terms
- --env-file — A Node.js command-line flag that loads variables from a .env file into process.env before your code runs, with no package needed.
- process.env — The object in Node.js that holds the process's environment variables, with every value stored as a string.
Taught in
- Runtime Configuration: CLI Flags & Native --env-file — Node.js Internals & Backend Services