Mik*_*lio 5 debugging node.js nodemon babeljs visual-studio-code
我可以让 VSCode 使用 NPM 运行脚本启动我的应用程序,然后附加到结果进程进行调试吗?
我的项目从 nodemon 通过 NPM 脚本开始(执行 babel 等)。但是,当应用程序启动时,VSCode 的调试器不会附加(跳过断点)。
// 来自 package.json
"scripts": { "debug": "nodemon --inspect --exec babel-node src/app.js" }
Run Code Online (Sandbox Code Playgroud)
// 来自launch.json
{
"type": "node",
"request": "launch",
"name": "Debug",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"debug"
],
"address": "localhost",
"port": 9229,
"protocol": "auto",
"restart": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"autoAttachChildProcesses": true
}
Run Code Online (Sandbox Code Playgroud)
调试器似乎启动了,但我放置在几个测试调用旁边的断点被忽略了。这是终端输出:
[nodemon] 1.19.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node --inspect src/app.js`
Debugger listening on ws://127.0.0.1:9229/13ef6ca8-40da-4741-854a-467e4230b2a7
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Hey!
Waiting for the debugger to disconnect...
[nodemon] clean exit - waiting for changes before restart```
Run Code Online (Sandbox Code Playgroud)