This process will create file package.json file under your project, where you can define scripts.
Run npm init under your project. Following file will be generated:

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}



Now you can update this file.

  "scripts": {
    "start": "node app.js"
  },
 

You can then run your app with just npm start. But if you make some change to the app, you must still quit the app and restart it. To automate this process we can use nodemon. --save-dev means that this package is used during development only.

npm install nodemon --save-dev



After installing nodemon you can change package.json:

  "scripts": {
    "start": "nodemon app.js"
  },
 



Then run your app with npm start and it will now look for any change you make and restart app automatically.