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:
const spawn = require('child_process').spawn;
const path = require('path');
const ls = spawn('node', [path.resolve('./child.js')], {execArgv: '--debug-brk=4545'});
ls.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
ls.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
});
ls.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});
child.js:
debugger;
const a = 123;
console.log(a);
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?