Skip to content

Instantly share code, notes, and snippets.

@thelbouffi
Last active April 21, 2019 21:14
Show Gist options
  • Save thelbouffi/04e21308e459188f6d5929696b4ac659 to your computer and use it in GitHub Desktop.
Save thelbouffi/04e21308e459188f6d5929696b4ac659 to your computer and use it in GitHub Desktop.
debug node app on vscode

Debug node

  • if we choose this config we will only need to run the debugger, it will be automatically attached to the app

Attach by Process ID

  • when we want to choose this config
  • we will need in first place to run the app with --inspect: node --inspect app.js or node --inspect .
  • then we will attach the debugger to it by choosing the option with --inspect

Attach to nodemon

  • this type of config is great for nodemon, because it help debugger attached to always to the same process via the same port
  • first run npx --inspect .
  • then attach the debugger
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to nodemon",
"port": 9229,
"restart": true
},
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}"
},
{
"type": "node",
"request": "launch",
"name": "Debug Node",
"program": "${workspaceFolder}/app"
},
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment