Shali’s Tech Blog Home.

FOURTH POST: Node.js

In my fourth post i’m going to talk some facts about Node.js, which is one of very famous javascript run-time in these days.

The first question that i’m going to answer for you is “What is Node.js?”

  • Javascript run-time(Not a Programming Language or a Framework)
  • Written with C++
  • Built-on v8 javascript engine(Same as Google Chrome)
  • Allow us to run javascript code on a server

Then let’s take a look at “Why we need to use Node.js?”

  • Fast, Efficient and Highly Scalable
  • Event driven, non-blocking I/O model(Asynchrones – only one thread running, don’t need to wait for other processes to complete, saving memory)
  • Popular in the industry(Full stack app development – MERN, MEAN)
  • Same language(js) on front-end and back-end(Rather than js front-end & back-end in another language like Python, C#, PHP sometimes might not be good)

Now we have a simple idea about what is Node.js and why we need it, also let’s see what types of projects that we can use Node.js as our server environment.

  • Rest API and Microservices
  • Real time services – Chat Apps,Live updates
  • CRUD apps – Blogs, Shopping carts, Social-networks

Let’s get into the main discussion now. I’m going to give some basic ideas about two words in Node.js vocabulary, which are NPM and node core modules.

  • NPM (Node Package Manager)

NPM is the standard package manager for node.js. We can install & manage 3rd party packages (Frameworks, Libraries, Tools) using NPM. These packages that we install using NPM will stored inside a folder called “node_modules” and all the dependencies related to these packages will stored inside a file called “package.json”. “npm scripts” inside “package.json” file, can be used to run certain tasks(Run a server).

  • Some useful commands.

  • Node Core Modules.

There are many core modules coming with node to extends its functionalities. We can easily use these modules by bringing them to our files and we can do various things using them. Some of them are assert, buffer, http, os, timers, util , url etc..

  • Path module – Provide path info

  • OS module – Provide information about OS/ environment

  • File system module – File handling operations

  • Url module – Get information from an url

  • Http module – Handle http requests

  • Event module

-Prabath Shalitha (2020 Feb 28)

Design a site like this with WordPress.com
Get started