watch: `NODE_OPTIONS=--watch` causes infinite loop
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.3k
- Merge trung bình
- 4 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 283
Mô tả
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?
- Write the following to
test.jsand make it executable:#!/usr/bin/env node console.log('hello'); 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/.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện lệnh của executable entrypoint với NODE_OPTIONS="--watch" và so sánh nó với issue #51159. Theo dõi cách executable và package bin entrypoint được xử lý trong watch mode, sau đó thêm hoặc cập nhật một regression test; hoàn thành khi lệnh in hello một lần rồi thoát mà không tạo process.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, node.js
- Lĩnh vực
- cli, developer-experience
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 55/100