Skip to content

src: return error --env-file if file is missing

Motivated by https://github.com/nodejs/node/issues/50536

NodeJS currently supports env file parsing. However, in cases where the file is missing, the process continues to execute. Since the env file is a crucial file, I propose that we return an error if the env file is missing. This will prevent errors in the future and allow us to detect them as early as possible.

Testing Scenario:

Given files tree:

└── test/
    ├── hello.js
    └── test.env

run: node --env-file=test.env hello.js
output: it will executed


└── test/
    ├── hello.js
    └── test.env

run: node --env-file=oops.env hello.js
output: node: oops.env not found


└── test/
    ├── hello.js
    └── test.env
    └── test1.env

run: node --env-file=test.env --env-file=test1.env hello.js
output: it will executed

└── test/
    ├── hello.js
    └── test.env
    └── test1.env

run: node --env-file=test.env --env-file=oops.env hello.js
output: node: oops.env not found

Merge request reports

Loading