IT3501-FULL STACK WEB
DEVELOPMENT
NODE.JS INTRODUCTION & INSTALLATION
Prepared by
S.Sakkaravarthi, AP/IT
Ramco Institute of Technology, Rajapalayam
AGENDA
Introduction to Node.js
Features of Node.js
Installation of Node.js
Creating a Simple Node.js program
Node Package Manager
Node.js Module-HTTP
Introduction to Node.js
Node.js is an Open Source run time environment for
Server-Side and networking applications
It is Cross Platform environment and can run on any
platforms
Uses Google Javascript V8 Engine to execute code
Introduction to Node.js
Node.js provide a library to run javascript applications
outside the browser
Node.js allows us to use JavaScript as a Server side
language
Easy to Communicate with Database
Features of Node.js
Asynchronous
Single Threaded and Event-Driven
Very Fast
Scalable
Asynchronous
Asynchronous
1. When request is made to Server, instead of waiting for the
request to complete, Server continues to process other requests
2. When request processing completes, the response is sent to
caller using callback mechanism
Single Threaded and Event-Driven
Single Threaded and Event-Driven
Single Threaded
Client send requests to Web Server
Node.js adds the requests to the Event Queue
Event Loop checks if the requests are simple enough not to
require any external resources
Single Threaded
Event Loop processes simple requests and returns the responses to
the corresponding clients
A Single thread from Thread pool is assigned to a single complex
request
Thread Pool performs the required task and returns the response to
Event Loop, which in turn response to the client.
Very Fast & Scalable
Very Fast & Scalable
1. Being built on Google Chrome’s V8 Javascript Engine,
Node.js library is very fast in code execution
2. Node.js is highly scalable because event mechanism helps
the server to respond in a non-blocking way.
Node.js Installation
Node.js Installation
Steps to be followed in Creating a Simple Node.js Program
Import HTTP Module
Define Port No
Creating Server Instance
Sending HTTP Header
Sending Data
Binding Server Instance with Port no 3000
Simple Node.js Program to display a Welcome Message
Simple Node.js Program to display a Welcome Message
Blocking Vs Non-Blocking I/O
Blocking Vs Non-Blocking I/O
Blocking Vs Non-Blocking I/O
Incase of Asynchronous (non-blocking), once file I/O complete, it
will call the call back function
This allows Node.js to be scalable and process large number of
request without worrying about blocking I/O.
Node Package Manager
NPM stands for Node Package Manager
Provides online repositories for node.js packages/modules
Provides command line utility to install Node.js packages along
with version management and dependency management.
HTTP –Node.js Module
HTTP –Node.js Module