Is there a way to automatically restart the node debugger in VS Code when a source file changes like nodemon?
Asked
Active
Viewed 5,826 times
8
-
You can just use nodemon :) The debugger will work with it. – Rob Lourens Jan 29 '17 at 21:44
-
Unfortunately NO. – J Santosh Feb 19 '17 at 04:33
2 Answers
9
You can use nodemon even for debugging. Below are the steps to configure in VS Code
- Open VSCode
- On top toolbar, go to Run > Add Configuration
launch.json
file will be created. Open that file and change as below
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\**app.js**",
**"restart": true,
"runtimeExecutable": "nodemon"**
}
]
Make sure nodemon is installed globally. Also your entry point to server is app.js
, if its different change it to that file name.

Mark
- 143,421
- 24
- 428
- 436

Emmad Zahid
- 438
- 6
- 15
2
You cannot automatically restart the node debugger when the source file changes, but you could use a separate debugger that does monitor source file changes such as node-inspector.
node-inspector developed by StrongLoop also has a feature that allows you to edit your source code within the debugger while the server is running.
Install node-inspector
$ npm install -g node-inspector
Start the node-inspector server
$ node-inspector
Enable debug mode in your node process
$ node --debug your/node/program.js
Load the debugger UI
Open http://127.0.0.1:8080/?port=5858 in the Chrome browser

Steve Ermish
- 113
- 1
- 9