nodejs / nodejs/node

watch: `NODE_OPTIONS=--watch` causes infinite loop

Offen
#61,740 7 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

confirmed-bug watch-mode
Vorherrschende Sprache
JavaScript
Sterne
122k
Forks
37.3k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
283

Beschreibung

Version

v25.6.0

Platform
Darwin <redacted> 24.6.0 Darwin Kernel Version 24.6.0: Wed Nov  5 21:33:58 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6000 arm64 arm Darwin
Subsystem

No response

What steps will reproduce the bug?
  1. Write the following to test.js and make it executable:
    #!/usr/bin/env node
    console.log('hello');
    
  2. NODE_OPTIONS="--watch" ./test.js
How often does it reproduce? Is there a required condition?

This is always reproducible.

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

I would expect it to run normally, producing hello in stdout and then exiting.

What do you see instead?

There is no output. I can see in my process list that there are hundreds of node processes spawning.

Additional information

This seems to be the same issue as https://github.com/nodejs/node/issues/51159. For additional context, my intent was to reuse a bin entrypoint in package.json but with --watch mode, so under the scripts field it looked roughly like:

"scripts": {
    "dev": "NODE_OPTIONS='--watch' app",
}

...where app is in node_modules/.bin/.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, den Befehl für den ausführbaren Einstiegspunkt mit NODE_OPTIONS="--watch" zu reproduzieren, und vergleiche ihn mit Issue #51159. Verfolge anschließend die Behandlung des ausführbaren Einstiegspunkts und des package-bin-Einstiegspunkts im Watch-Modus, und füge dann einen Regressionstest hinzu oder aktualisiere ihn; abgeschlossen ist die Aufgabe, wenn der Befehl hello einmal ausgibt und beendet wird, ohne Prozesse zu starten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, node.js
Bereich
cli, developer-experience
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.