diff --git a/doc/api/cli.md b/doc/api/cli.md index 4028e0d374b179..3b8512abcd9cbc 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -828,6 +828,8 @@ in the file, the value from the environment takes precedence. You can pass multiple `--env-file` arguments. Subsequent files override pre-existing variables defined in previous files. +An error is thrown if the file does not exist. + ```bash node --env-file=.env --env-file=.development.env index.js ``` @@ -867,6 +869,9 @@ Export keyword before a key is ignored: export USERNAME="nodejs" # will result in `nodejs` as the value. ``` +If you want to load environment variables from a file that may not exist, you +can use the [`--env-file-if-exists`][] flag instead. + ### `-e`, `--eval "script"` + +Behavior is the same as [`--env-file`][], but an error is not thrown if the file +does not exist. + ### `--pending-deprecation`