KEMBAR78
Lecture 9 Node Js | PDF | Software | Computer Science
0% found this document useful (0 votes)
20 views38 pages

Lecture 9 Node Js

Node.js is a JavaScript runtime built on Chrome's V8 engine, designed for building fast and scalable network applications, particularly suited for data-intensive real-time applications. It features an event-driven, non-blocking I/O model and is used for developing back-end services or APIs. The document outlines its basic concepts, parts, features, environment setup, and appropriate use cases, emphasizing its popularity among developers due to its open-source nature and extensive library support.

Uploaded by

Ma RA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views38 pages

Lecture 9 Node Js

Node.js is a JavaScript runtime built on Chrome's V8 engine, designed for building fast and scalable network applications, particularly suited for data-intensive real-time applications. It features an event-driven, non-blocking I/O model and is used for developing back-end services or APIs. The document outlines its basic concepts, parts, features, environment setup, and appropriate use cases, emphasizing its popularity among developers due to its open-source nature and extensive library support.

Uploaded by

Ma RA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Table of Contents

01 Basic Concepts Where to and Use


06
Node.js

02 Description
07 Conclusion

03 Parts
08 Activity 1

04 Features

09
04
04 Activity 2
05 Environment Setup
01
Basic
Consepts
Concepts of Node.js

1.Node.js was created in 2009 by Ryan Dahl. A web


developer, after he faced some difficult issues by
developing features with intense input and output flow
using synchronous programming and multi-threaded
server-side platforms.
2.In 2015, The Node.js Foundation was created as a Linux
Foundation project to accelerate the development of the
Node.js platform.
02
Description
What is Node.js
- Node.js is a platform built on Chrome's
JavaScript runtime for easily building fast and
scalable network applications. Node.js uses an
event-driven, non-blocking I/O model that makes it
lightweight and efficient, perfect for data-
intensive real-time applications that run across
distributed devices.

- Node.js is a side server platform. It is known as


the platform used to build back-end services also
known as API’s (Application Programming
Interfaces).It considered as the services that client
applications.
API’s a software intermediary that allows two applications to talk to
each other. like any other interface, it allows interactions. In the case of
an API, it allows interactions between systems by following a set of
standards and protocols in order to share features, information and
data.
03
Parts
Parts of Node.js
Console
The console is a module that provides a
method for debugging that is similar to the
basic JavaScript console provided by
internet browsers. It prints messages to
stdout and stderr.
Cluster
A cluster can be added to an application
Node.js is built on the concept of single- in the following way:
threaded programming. Cluster is a
module that allows multi-threading by
creating child processes that shares the
same server port and run simultaneously
Global

Global objects in Node.js are available in


all modules. These objects are
functions, modules, strings, etc. Some
Node.js global objects are mentioned in
the table below:
Global Objects Description

Specifies the name of the directory the contains the code of


_dirname application

Specifies the filename of the code


_filename

A reference type to the module exports, shorter to type


exports

module A reference to the current

require Used to import modules, local files, and also JSON


Error Handling
Node.js application experience four types of errors.
Streaming
Streams are the objects that let you read data or write data
continuously. There are four types of streams:

1. Readable: These are the types of streams from which data can be
read.

2. Writable: These are the types of streams to which data can be written.

3. Duplex: These are both readable and writable streams.

4. Transform: Streams that can manipulate the data while it is being


read or written.
Buffer
Buffer is a module that allows the handling of streams that contain only binary
data. An empty buffer of length '10' can be created by this method:
Domain
The domain module intercepts errors that remain unhandled. Two
methods are used for intercepting these errors:

1. Internal Binding: Error emitter executes its code inside the run
method.
2. External Binding: Error emitter is explicitly added to a domain via it’s
add method.
DNS

DNS module is used to connect to a DNS server and perform name resolution
by using the following method:
DEBUGGER
Node.js includes a debugging utility that can be accessed by a built-in
debugging client. Node.js debugger is not feature-packed but supports the
simple inspection of code. The debugger can be used in the terminal by
using the 'inspect' keyword before the name of the JavaScript file. In order
to inspect a file—myscript.js, for example—you can follow this method:
Node.js can:

Create, open, read, Generate


write, delete, and dynamic page
closes file on the server content

Add, delete, change


Collect form data data in your
database
04
Features
Features of Node.js
Single Threaded
but Highly
Scalable
Non-Blocking No
I/O Buffering

Node
Package Very
Manager fast
Asynchronous
and Event Driven
05
Environment
Setup
Environment Setup of Node.js

If you are still willing to set up your environment for Node.js, you need the following two
software’s available on your computer, (a) Text Editor and (b) The Node.js binary installable

This will be used to type your program. Examples of few editors include Windows Notepad, OS Edit command,
Brief, Epsilon, EMACS, and vim or vi.

Name and version of text editor can vary on different operating systems. For example, Notepad will be used on
Windows, and vim or vi can be used on windows as well as Linux or UNIX.

The files you create with your editor are called source files and contain program source code. The source files
for Node.js programs are typically named with the extension ".js".

Before starting your programming, make sure you have one text editor in place and you have enough
experience to write a computer program, save it in a file, and finally execute it.
The Node.js
Runtime
The source code written in source file is simply
javascript. The Node.js interpreter will be used
to interpret and execute your javascript code.

Node.js distribution comes as a binary


installable for SunOS , Linux, Mac OS X, and
Windows operating systems with the 32-bit
(386) and 64-bit (amd64) x86 processor
architectures.
Download Node.js Archive
Download latest version of Node.js installable archive file
from Node.js Downloads. At the time of writing this tutorial,
following are the versions available on different OS.

OS Archive Name

Windows node-v6.3.1-x64.msi

Linux node-v6.3.1-linux-x86.tar.gz

Mac node-v6.3.1-Darwin-x86.tar.gz

SunOS node-v6.3.1-x86.tar.gz
Installation on Windows

Use the MSI file and follow the prompts to install


the Node.js. By default, the installer uses the
Node.js distribution in C:\Program Files\nodejs.
The installer should set the C:\Program
Files\nodejs\bin directory in window's PATH
environment variable. Restart any open command
prompts for the change to take effect.
Verify Installation: Executing a File

▪ Create a js file named main.js on your machine (Windows) having the


following code.
/* Hello, World! program in node.js */console.log("Hello, World!")

▪ Now execute main.js file using Node.js interpreter to see the result
$ node main.js

▪ If everything is fine with your installation, this should produce the


following result

Hello, World!
06
Where to
Use Node.js
Where to Use Node.js?

Following are the areas where Node.js


is proving itself as a perfect
technology partner.
• I/O bound Applications
• Data Streaming Applications
• Data Intensive Real-time
Applications (DIRT)
• JSON APIs based Applications
• Single Page Applications
Where Not to Use Node.js?

It is not advisable to
use Node.js for CPU
intensive applications.
498,300,000
Big numbers catch your
audience’s attention
Popular Companies that Utilized Node.js
07
Conclusion
Conclusion
Node.js is a very powerful JavaScript-based framework/platform built on
Google Chrome's JavaScript V8 Engine. It is used to develop I/O intensive web
applications like video streaming sites, single-page applications, and other
web applications. Node.js is open source, completely free, and used by
thousands of developers around the world.

One of the primary factors behind Node.js’ popularity among developers is its
support for thousands of open-source libraries, a large majority of which are
hosted on the npm website.

Node.js was built at the right place and time. It introduced a lot of
approaches for JavaScript server-side development and innovative
thinking that has helped many developers.
Activity 2
Top Rated Values
To modify this graph, click on it, follow the link, change the data and paste the new graph here
To modify this graph, click on it, follow the link, change the data and paste the new graph here
References

● https://www.simplilearn.com/tutorials/nodejs-tutorial/what-is-nodejs

● https://www.tutorialspoint.com/nodejs/nodejs_introduction.htm

● https://www.tutorialspoint.com/nodejs/nodejs_environment_setup.htm

● https://www.tutorialspoint.com/nodejs/nodejs_environment_setup.htm

● https://www.tutorialspoint.com/node_js_online_training/index.asp

● https://dev.to/cassiocappellari/fundamentals-of-rest-api-2nag
Thank You!

Slidesgo

CREDITS: This presentation template was created by Slidesgo, including


Flaticon Freepik

icons by Flaticon, infographics & images by Freepik and illustrations by


Stories

Stories

You might also like