Skip to content

dotenv.config() override doesn't have a defined behavior #917

@HoppoPrj

Description

@HoppoPrj

Hello!
I'm loading multiple .env files using the following:
dotenv.config({path: path.join(process.cwd(), currentPath), override: true});

From docs, i understood variables are overridden only when they exist on the next .env file.

"Override any environment variables that have already been set on your machine with values from your .env file(s). If multiple files have been provided in option.path the override will also be used as each file is combined with the next. Without override being set, the first value wins. With override set the last value wins."

also on the actual interface:
"Override any environment variables that have already been set on your machine with values from your .env file."

however, i noticed that if the file doesn't exist at all, no env file is being loaded. i haven't found any mention of that in the docs.
it seems like an ill defined behavior. my intuation is that if the file doesn't exist, meaning there are no values in the .env file, it doesn't override anything, because it has no values...

I think it should at least be mentioned somehow.
Also maybe i missed something, thanks! 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions