Skip to content

Instantly share code, notes, and snippets.

@ola-dola
Last active February 6, 2022 21:22
Show Gist options
  • Save ola-dola/861f92e6be797dbb2a335adad7bd4fbd to your computer and use it in GitHub Desktop.
Save ola-dola/861f92e6be797dbb2a335adad7bd4fbd to your computer and use it in GitHub Desktop.
Restarting debug sessions automatically when source is edited using nodemon (without global install)
  • Add a script to start app with nodemon in inspect mode: "server": "nodemon --inspect server.js"
  • Add the following config to vscode's launch.json:
{
  "name": "Attach to node",
  "type": "node",
  "request": "attach",
  "restart": true,
  "port": 9229
}
  • Run app with npm run server. The debugger is automatically attached.

NB: Clicking the debugger's stop button doesn't end the node/nodemon process. You'd have to kill it the terminal(where you ran the script originally).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment