-
-
Notifications
You must be signed in to change notification settings - Fork 34.6k
Closed
Labels
dotenvIssues and PRs related to .env file parsingIssues and PRs related to .env file parsingwatch-modeIssues and PRs related to watch modeIssues and PRs related to watch mode
Description
Version
23.7.0
Platform
Linux fedora 6.12.11-200.fc41.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jan 24 04:59:58 UTC 2025 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:
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,--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/github/template-discordbot/.env'
at FSWatcher.<computed> (node:internal/fs/watchers:247:19)
at watch (node:fs:2551: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/github/template-discordbot/.env',
filename: '/home/mkvlrn/github/template-discordbot/.env'
}
Node.js v23.7.0
.env not found. Continuing without it.
node:events:485
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 #createModuleJob (node:internal/modules/esm/loader:552:15)
at #getJobFromResolveResult (node:internal/modules/esm/loader:312:34)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:280:41)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:582:25)
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 v23.7.0Additional information
Neither --watch nor --env-file /--env-file-if-exists documentations warn about not combining these flags.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
dotenvIssues and PRs related to .env file parsingIssues and PRs related to .env file parsingwatch-modeIssues and PRs related to watch modeIssues and PRs related to watch mode