Repository navigation
Description
Version
v22.14.0
v24.13.1, v25.6.1
Platform
Linux arch 6.13.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 08 Feb 2025 18:54:55 +0000 x86_64 GNU/Linux
Linux archlinux 6.18.9-zen1-2-zen #1 ZEN SMP PREEMPT_DYNAMIC Mon, 09 Feb 2026 17:45:06 +0000 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
Run any script in a project where a .env file doesn't exist:
mkdir repro && cd repro && npm init -y && echo "console.log('repro');" > main.js
node --env-file-if-exists=.env --watch main.jsIf the .env file exists or you don't use the --watch flag, script runs normally without throwing errors.
How often does it reproduce? Is there a required condition?
These need to be true for the problem to occur:
- use the flag
--env-file-if-existspointing to a non existing .env file, like--env-file-if-exists=.env - use the flag
--watch
What is the expected behavior? Why is that the expected behavior?
Script should run normally with the following message being printed right before it:
.env not found. Continuing without it.
What do you see instead?
An error stating .env was not found.
.env not found. Continuing without it.
node:internal/fs/watchers:247
const error = new UVException({
^
Error: ENOENT: no such file or directory, watch '/home/mkvlrn/sandbox/repro/.env'
at FSWatcher.<computed> (node:internal/fs/watchers:247:19)
at watch (node:fs:2550:36)
at FilesWatcher.watchPath (node:internal/watch_mode/files_watcher:109:21)
at FilesWatcher.filterFile (node:internal/watch_mode/files_watcher:128:12)
at start (node:internal/main/watch_mode:78:13)
at init (node:internal/main/watch_mode:148:15)
at node:internal/main/watch_mode:160:1 {
errno: -2,
syscall: 'watch',
code: 'ENOENT',
path: '/home/mkvlrn/sandbox/repro/.env',
filename: '/home/mkvlrn/sandbox/repro/.env'
}
Node.js v22.14.0
.env not found. Continuing without it.
repro
node:events:496
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at target._send (node:internal/child_process:877:20)
at target.send (node:internal/child_process:751:19)
at reportModuleToWatchMode (node:internal/modules/cjs/loader:279:13)
at Function._load (node:internal/modules/cjs/loader:1097:5)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
at node:internal/main/run_main_module:36:49
Emitted 'error' event on process instance at:
at node:internal/child_process:881:39
at process.processTicksAndRejections (node:internal/process/task_queues:85:11) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}
Node.js v22.14.0Additional information
This is almost a 100% copy of a previous issue (#56887) I had opened a couple weeks back, but that issue was found on the latest/23 version, while not present in the then current LTS v22.13.1. Now it is happening in the LTS 22.14 version. Still working fine in 22.13.1.


Activity
mkvlrn commentedon Feb 28, 2025
Also happening in latest
v23.9.0(Not sure if I should update this wit this info or create a new one. This seems better.)
029A-h commentedon Jun 25, 2025
It’s still happening in version 24.2.0.
mkvlrn commentedon Feb 17, 2026
Updated versions in original report: still happening in both LTS (24.13.1) and current (25.6.1).
Docs state that flag is no longer experimental since 24.10.0.
efekrskl commentedon Feb 17, 2026
Thanks for reporting this. I'm on Node version v25.6.1 and macOS 15.7.3, and this seems to work fine.
However, I was able to reproduce this inside docker containers with Linux (both LTS and latest). Definitely something is wrong. I'll try looking into it