Use nodemon to auto restart

Nodemon is a utility that monitors for changes in your source code and automatically restarts the server when changes are detected. To use Nodemon, you'll need to install it globally or locally in your project, and then you can start your server with Nodemon.

To install nodemon globally

npm install -g nodemon

To install locally in project

npm install --save-dev nodemon 

Use Nodemon to Start Your Server

nodemon server.js