Automatically Restart Node.js Server Using Nodemon

How to Automatically Restart Node.js Server Using Nodemon

1 Nodemon installation

nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected [nodemon]

npm install --save-dev nodemon

2 Nodemon configration in package.json (Optional)

{
  "name": "mean-course",
  //...
  "scripts": {
    //...
    "dev": "nodemon server.js",
  },
}

3 Run Nodemon

#With package.json config
npm run dev
#Without package.json config
nodemon server.js