Skip to content

Add --env-file-if-exists #50993

Closed
Closed
@mbrevda

Description

@mbrevda

What is the problem this feature will solve?

#50588 introduced a throw if a requested env file isn't found. When dealing with multiple environments, a .env file may sometimes be merely optional - and throwing isn't desired. For example, during local development, devs might keep variables in a .env file, which isn't committed to source control, while in production, these variables come from the environment. This option will allow the env file to be loaded only if it exists without changing the command used to invoke node between environments.

What is the feature you are proposing to solve the problem?

Add a flag (or other mechanism) to indicate that the .env file should be loaded only it's found, and to throw otherwise.

What alternatives have you considered?

touching .env before running node; invoking node via a shell script and "building up" the cli opts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dotenvIssues and PRs related to .env file parsingfeature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions