I am using Visual Studio Code as my editor for NodeJS project.
Currently I need to manually restart server when I change files in my project.
Is there any plugin or configuration change in VSCode that can restart NodeJS server automatically when I make change in files.
You can now use Nodemon with VS Code to achieve this. I tested the Nodemon support for VS Code today and it worked well for me. Below are my VS Code details.
I installed Nodemon globally npm install -g nodemon
and created VS Code launch configuration as below
{
"name": "Nodemon Launch Server",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "nodemon",
"runtimeArgs": [
"--debug=5858"
],
"program": "${workspaceRoot}/server.js",
"restart": true,
"port": 5858,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
Reference: https://code.visualstudio.com/docs/editor/node-debugging#_restarting-debug-sessions-automatically-when-source-is-edited
You can also install nodemon locally npm install nodemon --save-dev
.
And the following example of configurations of VS Code launch.json:
[
{
"name": "Nodemon",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
"program": "${workspaceFolder}/src/server/index.js",
"restart": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With