Skip to content

Multiple --env-file no longer work with --watch #60599

@tclzcja

Description

@tclzcja

Version

v25.1.0

Platform

Microsoft Windows NT 10.0.26200.0 x64

Subsystem

No response

What steps will reproduce the bug?

  1. Create .a.env, and .b.env.
  2. .a.env includes: "ENV_VAR_A=123".
  3. .b.env includes: "ENV_VAR_B=456".
  4. create index.js that does this:
console.log(process.env.ENV_VAR_A)
  1. Run "node --env-file=.a.env --env-file=.b.env --watch index.js".
  2. Result output "undefined" (instead of 123)

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

Expected to see "123", because both .env files should be included and loaded as the command says. Notice that the env vars in those 2 files are different, so those 2 files should be "merged" as result, instead of be completely overwritten by the last one.

What do you see instead?

It always output "undefined" when "--watch" is added. It does output "123" when "--watch" is removed.

Additional information

Until Node.js v24.4, the multiple --env-file works well with --watch. I updated to v25.1.0 yesterday, and this pattern no longer works. As I've mentioned above, highly likely this is caused by "--watch" flag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions