-
Notifications
You must be signed in to change notification settings - Fork 28.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot debug node child process (using node native debugger) #8690
Comments
If you are spawning child processes, you need to pass |
Thanks @bnoordhuis - i tried that without success, maybe I'm doing something wrong? In my example, I tried (inside process.execArgv.push('--inspect=' + (9223));
const ls = child.spawn('node', [path.resolve('./child.js')]); I then opened both child and index devtools (child first and then index). I was expecting to hit breakpoints on child while running index.js, but it didn't work |
That doesn't work for spawn(), you may be thinking of fork(). Explicitly pass const file = path.resolve('./child.js');
const args = ['--inspect=9223', file];
const proc = cp.spawn(process.execPath, args); |
Thanks! This is working now. I really think we should add docs for debugging child processes/cluster to the node debug section. This can be really tricky and documentation almost doesn't exists! |
You can open a documentation pull request if you want, the files to look for are in doc/api. |
@yanivefraim : I follow the suggestion but it is not working at all. Here is my code for start spawn process: server = cp.spawn('node', [serverPath, '--inspect=9223'], { Could you help? Is there anything wrong here? |
@quyetvv - maybe this will help: https://github.com/yanivefraim/node-debug-childprocess/blob/master/index.js |
Related issue: #9435 (prematurely closed) |
I'm trying to debug node child process, using native node debugger. See this repo for example.
I tried all king of options, according to: debug1, debug1, debug3 (and a lot of other references I found online).
Non of those options worked for me..
This is my example code:
index.js:
child.js:
I then run:
node --debug-brk --inspect=9222 index.js
And I open the
chrome-devtools://devtools/...
in chrome. Debugging the main process works great, and I see the child process output as well. Only thing that is not working is debug of child process...What am I doing wrong here?
The text was updated successfully, but these errors were encountered: