📄 Table of contents

➤ why nodeJS is NOT a Framework

  • Modules

◉ all about nodeJS

  • First of all, NodeJS is NOT a framework.
  • Node.js uses Asynchronous programming!
  • Node.js runs single-threaded, non-blocking, ASYNCchronously programming, which is very memory efficient.
  • It can run Javascript outside the browser. Basically, It is Javascript running on the server.
  • It is built on Chrome’s V8 Javascript engine and V8 is written in C++.
  • works on a single thread using non-blocking I/O calls.
  • supports tens of thousands of concurrent connections.
  • Node.js is an open source server environment.
  • Node.js is Cross-platform framework that runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
  • Node.js implements CommonJS modules standard.
  • Node.js files have extension “.js”

◉ Why is nodeJS NOT considered a Framework ?

  • Node.js includes that interpreter separately which requires to execute code. It takes this power from the chrome v8 engine which is used in chrome to run JavaScript. And, it extends the power of handling file and network I/O with a preference for asynchronous patterns. In simple words, we can do a lot of things in NodeJS which are not possible with JavaScript like network I/O, File handling, etc. For security reasons, JavaScript originally did not include file I/O for use in the browser. And, it did not need to do networking tasks, because the browser does them. JavaScript was built out with the DOM for the browser.

◉ What is NPM?

  • NPM is a package manager for Node.js packages, or modules if you like.
  • It is the largest ecosystem of open source libraries in the world.
  • The NPM program is installed (by default) on your computer when you install Node.js.
  • Once you have downloaded and installed your first package say : “xyz” using npm install xyz, NPM creates a folder named “node_modules”, where the package xyz will be placed. All packages you install in the future will be placed in this folder.

Modules in NodeJS?

Consider modules to be the same as JavaScript libraries.

var http = require(‘http’);
var express = require('express');
var fs = require('fs');

◉ Callbacks in nodeJS

Node JS handle all Asynchronous calls via callback. Hey wait, what is callback..?? well, callbacks in the general definition are just functions that you pass to other functions. It is called at the completion of certain task.

  1. Callback : a callback function, and assign that function to a constant variable checkFileType.
  1. A callback function

◉ A Simple NodeJS server (without Express JS)

The code tells the computer to write “Hello World!” if anyone (e.g. a web browser) tries to access your computer on port 3000/8000/etc.

Creating Simplest server using “http” module
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
var url = req.url;
if(url ==='/about'){
res.write('<h1>about us page<h1>');
else if(url ==='/contact'){
res.write('<h1>contact us page<h1>');
res.write('<h1>Hello World!<h1>');
}}).listen(3000, function(){
console.log("server start at port 3000");
//the server object listens on port 3000


While doing development on any NodeJS application, whenever we make any change to some file, every-time we need to restart our Node server from the command prompt/terminal. This is a repetitive process since we make hundred of changes and restart the server every time to check the change.

npm install nodemon -g

What is ExpressJS?

Express is a really cool Node framework that’s designed to help JavaScript developers create servers really quickly. NodeJS may be server side, but it can do a whole lot more than just serve pages and data. NodeJS is a powerful platform that lets you run JavaScript on your shell similar to how you’d run Python.

◉ Building a simple REST API with NodeJS and Express.

If you’re been building apps using HTML, CSS and JavaScript, you may want to learn how to build servers that serve content to these front end technologies.

download the most stable release of NodeJS.
Open cmd => check for
npm -v
node -v
to confirm that above installation has been successful
npm install express — save
var express = require(“express”);
var app = express();
app.listen(3000, () => {
console.log(“Server is running on port 3000”);
node app.js

◉ how to server Static files in nodeJS.

create a Public folder inside root folder and place all .css files inside this folder.

Building a Node.js API using nodeJS + Express + MongoDB

refer this link.

What Is Better Node JS Or Angular JS?

Both NodeJS and AngularJS platforms are targeted at building web applications using JavaScript. However, both of them are different in their architecture and working.

NW.js (formerly node-webkit)

You can write desktop apps using websites (HTML, CSS, JavaScript) while retaining access to all Node.JS features and APIs.

  • Complete support for Node.js APIs and all its third party modules.
  • Good performance: Node and WebKit runs in the same thread: Function calls are made straightforward; objects are in the same heap and can just reference each other;
  • Easy to package and distribute apps.
  • Available on Linux, Mac OSX and Windows

Experience with Front-end Technologies and MERN / MEAN Stack. Working on all Major UI Frameworks like React, Angular.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store