Skip to content

Throw an error or output a warning when --env-file can not be opened. #50536

Closed
@virtuallyunknown

Description

@virtuallyunknown

What is the problem this feature will solve?

Greetings! Thanks a lot for implementing --env-file directly into Node.

I am currently using Node v20.9.0 on Linux, and if you run node with the --env-file option that points to a file that can't be reached, it still will execute the program as if everything went fine. For example:

node --env-file=non_existing_file.env my_app.js

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

This is not an uncommon scenario that you can find yourself in, and it can occur for various reasons. For example if you are working in a monorepository and the context of the current working directory changes, or if you lack sufficient permissions to open the file.

I think it would be beneficial for developers if an error or a warning was shown if the env file can't be opened.

What alternatives have you considered?

I have been using the dotenv package and currently in the process of migrating to native --env-file instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.good first issueIssues that are suitable for first-time contributors.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions