Skip to content

When --env-file is used with --watch-path, the process is restarted when files outside the specified path are changed #62229

@fedyk

Description

@fedyk

Version

v25.6.1

Platform

Darwin Mac.home 24.6.0 Darwin Kernel Version 24.6.0: Mon Jan 19 22:01:08 PST 2026; root:xnu-11417.140.69.708.3~1/RELEASE_ARM64_T8112 arm64

Subsystem

watch_mode

What steps will reproduce the bug?

Create a project with following files:

cache/test.txt
src/index.js
.env

Paste any long running JS into src/index.js. For example:

import { createServer } from 'node:http';

const server = createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello World!\n');
});

server.listen(3000, '127.0.0.1', () => console.log('Listening on 127.0.0.1:3000'));

Start the process with following command:

node --watch-path=./src --env-file=.env src/index.js

In separated terminal call

cat "test" >> cache/test.txt

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

Each time

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

The changes outside the --watch-path should be ignored when --env-file is used.

What do you see instead?

Changes outside --watch-path cause node process to restart

Additional information

No response

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