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

前端 未结 5 2386
别那么骄傲
别那么骄傲 2021-02-19 19:42

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 s         


        
5条回答
  •  感动是毒
    2021-02-19 19:48

    You can easily add a new launch configuration to launch.json that allows you to attach to a running node instance with a specific port:

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

    Just make sure you fork/spawn your node process with the --debug or --debug-brk argument.

提交回复
热议问题