Skip to content

Support absolute paths with the --env-file CLI option. #51625

Closed
@virtuallyunknown

Description

@virtuallyunknown

What is the problem this feature will solve?

Well, the problem is really simple. Right now when you pass a file to --env-file such as:

node --env-file=.env

It will load correctly, provided you have a file called .env relative to the current working directory (as stated in the documentation).

However, if you call the command with an absolute path such as:

node --env-file=/home/user/some/path/.env

It will throw an error, even if the file exists:

node: /home/user/some/path/.env: not found

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

I propose that passing an absolute path to --env-file would detect it as such and try to load the file. Also, the current error message could be improved.

Supporting absolute paths might sounds like a niche feature, but it can be very useful in the context of mono-repositories.

What alternatives have you considered?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature 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