This is part two of the node tutorial.

How to add custom scripts to Node js -> ( like executing server custom commands [npm start])

run -> npm init

complete the questions


in package .json "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "node server.js" <- this is the script for start with -> npm start },


now you can start with -> npm start
for custom commands you have to use -> npm run <script name> (npm start is a special one)
 
  

NODEMON

  Nodemon is a utility tool -> run our server through it and it watches for changes -> automatically restart the server
 
  npm install nodemon -g    <- save nodemon globally
  npm install nodemon --save   <- production dependencies 
  npm install nodemon --save-dev   <-development dependencies 

 
  we only use nodemon for testing in developing.. so use --save-dev


  • package-loc.json <- this is for -> get the exact dependencies that installed initially
 
 
  change the script for auto-start nodemon and run
 
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon server.js"
  },
 
  now type -> npm start for start the server

    


Error types 

  1.Syntax Errors
  2.Runtime Errors
  3.Logical Errors