我想像rails一样调试node.js。我尝试了几种方法:
那么调试像byebug for rails这样的节点应用程序的最佳选择是什么?
升级:
感谢@AbhinavD我已经在VSCode中做到了:首先,您需要编辑app / .vscode / launch.js, javascript { "version": "0.2.0", "configurations": [ { "type": "node", "request": "attach", "name": "Node: Nodemon", "processId": "${command:PickProcess}", "restart": true, "protocol": "inspector", }, ] } 因此,现在nodemon在更改后重新启动服务器,并且VSCode自动重新连接到调试器。
javascript { "version": "0.2.0", "configurations": [ { "type": "node", "request": "attach", "name": "Node: Nodemon", "processId": "${command:PickProcess}", "restart": true, "protocol": "inspector", }, ] }
观看视频https://vimeo.com/267975071
有人可以在WebStorm中做到吗?
我不确定如何byebug运作。但是,如果使用VSCode和nodemon(全局安装),则VSCode可以将自身重新附加到正在运行的进程中,并且将在调试器的同一点中断。
byebug
这是我的配置文件的样子
{ "name": "Launch server.js via nodemon", "type": "node", "request": "launch", "runtimeExecutable": "nodemon", "program": "${workspaceFolder}/joiValidation.js", "restart": true, "console": "integratedTerminal", "internalConsoleOptions": "neverOpen" }
这是我通过调试制作的小视频。官方文件