VSCode does not stop at breakpoints when the first node prcess opens the second

The first problem is that there is some conflict error when you do the following from your app.js file and remove F5 for debugging:

var cp = require ('child_process'); var node2 = cp.fork ('./ app_FORK.js');

Error: listen to EADDRINUSE: 15838 in Object.exports._errnoException (util.js: 856: 11)

I had the same problem with VS Community, so I did the following there and it worked: var node2 = cp.fork ('./ app_FORK.js', [], {execArgv: ['--debug = 5859'] });

However, in VS Code it does not work. I put breakpoints or try to connect after starting node from the command line and it does not work.

+2
debugging child-process visual-studio-code
source share
1 answer

You are almost there, you just need to configure the launch.json file in the .vscode folder to attach the debugger to the child process.

json { "name": "Attach to Node", "type": "node", "address": "localhost", "port": 5859, }

Just create the child process on the correct port (you can install above) and use the argument --debug or --debug-brk.

0
source share

All Articles