如何在Visual Studio Code中调试子Node.JS进程?
问题描述:
如何在VS Code中调试子Node.JS进程?
这是我要调试的代码示例:
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]);
答
您可以轻松添加要启动的新启动配置。允许您使用特定端口连接到正在运行的节点实例的json:
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,
}
只需确保使用-debug 或- -debug-brk 参数。