使用到的是nodemon,具体在package.json文件中配置如下:
"scripts": { "start": "node ./bin/www", "debug": "nodemon --inspect ./bin/www" }
主要是需要有--inspect参数
然后在vscode中添加lauch.json的配置:
{ "version": "0.2.0", "configurations": [ { "type": "node", "request": "attach", "name": "Node: Nodemon", "processId": "${command:PickProcess}", "restart": true, "protocol": "inspector", }, ] }
之后在vscode的终端中正常运行npm run debug(自己在package.json里面配置的scripts脚本名称)
再运行vscode调试面板中刚配置的"Node: Nodemon",会弹出选择框让你选择正在运行的node进程,选择刚才脚本中配置的--inspect的进程,即可进行调试了。
详见:https://github.com/Microsoft/vscode-recipes/tree/master/nodemon