debug.js
#!/usr/bin/env node
// A wrapper to allow starting the index.js in debug mode port is 3000
const { spawn } = require('child_process')
var child = spawn('node', ['--inspect-brk=3000', 'index.js'], { stdio: 'inherit' })
launch.json
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "",
"runtimeExecutable": "${workspaceFolder}/../Tools/someprogramthatrunsmine",
"runtimeArgs": [
"mycommand-debug",
"someinputs"
],
"cwd": "${workspaceFolder}",
//"console": "integratedTerminal",
"port": 3000
}
]
package.json bin 命令
"bin": {
"mycommand-debug": "debug.js"
},
运行npm link链接命令进行本地测试。
现在,当我的 index.js 代码由不同的运行时可执行文件运行时,单击 Vscode 中的“调试”按钮可以对其进行断点。