I'd like to debug node.js like rails. I've tried several ways:
So what's the best option to debug node apps like byebug for rails?
Upgrade:
Thx to @AbhinavD I've managed to do it in VSCode:
First you need to edit app/.vscode/launch.js
javascript
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Node: Nodemon",
"processId": "${command:PickProcess}",
"restart": true,
"protocol": "inspector",
},
]
}
So now nodemon restarts server after changes and VSCode reconnect to debugger automatically.
See video https://vimeo.com/267975071
Is anybody able to do it in WebStorm?
I am not sure how byebug
works. However if you use VSCode and nodemon (installed globally), VSCode can reattach itself to the running process and will break at the same point in the debugger.
Here is what my config file looks like
{
"name": "Launch server.js via nodemon",
"type": "node",
"request": "launch",
"runtimeExecutable": "nodemon",
"program": "${workspaceFolder}/joiValidation.js",
"restart": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
Here is the small video I made from my debugging. Official documentation