Updating NPM scripts

Add NPM script to start the server,

Inside package.json file, add start script inside scripts.

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

If you are already running the server, stop it and then run the start script from the terminal.

npm start

How the npm script differs from the node script?

Both are doing the same. Running the web server at port 8080. The main difference is, NPM script will help to run long commands. Also helps to run more than one script with a single command. You don't need to memorize the full command and type every time. You can run the simple script command and do many operations at the same time.

Example:

{
  "prettify": "...",
  "lint": "...",
  "test": "...",
  "build-src": "...",
  "build": "npm run lint && npm run prettify && npm run test && npm run build-src"
}

This way, if you run npm run build. You can do many operations at the same time. You can do the same with the node command, but it will be difficult to remember all the time.