How to debug child Node.JS process in Visual Studio Code?

vicneanschi picture vicneanschi · Sep 16, 2015 · Viewed 7.8k times · Source

How to debug child Node.JS process in VS Code?
Here is the example of the code that I'm trying to debug:

var spawn = require('child_process').spawn;
var scriptPath = './child-script.js';
var runner_ = spawn('node', [scriptPath]);

Answer

Manoj Suthar picture Manoj Suthar · Jul 26, 2018

In your launch configuration add "autoAttachChildProcesses": true like shown below

{
  "type": "node",
  "request": "launch",
  "name": "Launch Program",
  "autoAttachChildProcesses": true,
  "program": "${workspaceFolder}/index.js"
}