How to debug Node.JS child forked process?

Yes. You have to spawn your process in a new port. There is a workaround to debug with clusters, in the same way you can do:

Start your app with the –debug command and then:

var child = require('child_process');
var debug = typeof v8debug === 'object';
if (debug) {   
    //Set an unused port number.    
    process.execArgv.push('--debug=' + (40894));    
}    
child.fork(__dirname + '/task.js');

debugger listening on port 40894

Leave a Comment