0% found this document useful (0 votes)
68 views19 pages

Introduction To Node: Submitted By, Sonel Chandra S7 Roll No-34

This document provides an introduction to Node.js submitted by Sonel Chandra. It discusses the history and purpose of Node.js, defining it as an open source server framework built on Chrome's V8 JavaScript engine. It allows JavaScript to be run on the server side and is asynchronous and event-driven. Popular uses of Node.js include I/O bound applications and real-time applications. The document also covers installing and using Node packages, modules, and the require function in Node.js. It provides an example of a simple "Hello World" Node app.

Uploaded by

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

Introduction To Node: Submitted By, Sonel Chandra S7 Roll No-34

This document provides an introduction to Node.js submitted by Sonel Chandra. It discusses the history and purpose of Node.js, defining it as an open source server framework built on Chrome's V8 JavaScript engine. It allows JavaScript to be run on the server side and is asynchronous and event-driven. Popular uses of Node.js include I/O bound applications and real-time applications. The document also covers installing and using Node packages, modules, and the require function in Node.js. It provides an example of a simple "Hello World" Node app.

Uploaded by

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

INTRODUCTION TO

NODE
SUBMITTED BY,
SONEL CHANDRA
S7
ROLL NO-34
history
• Node.js was developed in 2009 by Ryan Dahl. At that time, Apache
HTTP Server handled the things that Node.js does now, but with less
efficiency. Specifically, Apache couldn’t tackle concurrent requests.
Thus, Node.js was created
• With Node.js, JavaScript developers use server-side scripting to
manifest dynamic web pages. Server-side scripting works by running
user requests on the server-side, or web server, rather than on the
client-side, or web browser.
• The advantage of this scripting technique is that clients do not need to
deal with slow loading times and high CPU usage
WHAT IS NODE JS?
• Node.js is an open source server framework.
• Node.js is a JavaScript runtime built on Chrome's V8
JavaScript engine
• Node.js Uses an event-driven, non-blocking I/O makes it
lightweight and efficient.
• Node.js allows you to run JavaScript on the server.
• Node.js runs on various platforms (Windows, Linux, Unix,
Mac OS X, etc.)
WHY NODE.JS
• Node.js enables developers to use Javascript on the front- and backend as well. Every dev can understand what’s
happening on the entire stack, and make changes if necessary.
• Asynchronous and Event Driven - many connections can be handled concurrently.(Asynchronous I/O is a form
of input/output processing that permits other processing to continue before the transmission has finished.)
• (Event-driven programming is a programming paradigm in which the flow of the program is determined by
events such as user actions (mouse clicks, key presses), sensor outputs, or messages from other
programs/threads.)
• Node.js is the perfect tool for developing high-throughput server-side applications.
• Node.js scales flawlessly, so it can help you to save money on infrastructure costs.
• Being an open-source technology, Node.js is open-source and cross-platform means that the framework is
accessible in two ways.
• By way of being open-source, skilled developers can edit the Node.js source code to their liking, or otherwise
for the improvement of everyone involved.
• Secondly, as a cross-platform software, Node.js is available to virtually any developer no matter their preferred
operating system
• Companies that use Node.js know that JavaScript is the go-to language for building
dynamic websites. 
• But they want to take their dedication to JavaScript just a step further by utilizing the language
not only for front-end development, but back-end development too. 
• Node.js is a platform many skilled web developers are using today to amp up their back-end
development while still using the same tried-and-true language – JavaScript.
• LinkedIn Netflix Uber Trello PayPal
• NASA eBay
• Medium
• Groupon
• Walmart
• Mozilla 
5
WHERE ALL NODE.JS
• I/O bound Applications
• Data Streaming Applications
• JSON APIs based ApplicationsReal-Time Chats,
• Complex Single-Page applications,
• Real-time collaboration tools,
Architecture of node.js
VALIDATE NODEJS INSTALLATION
Printing hello world
Hello world
• Create a file named app.js containing the following contents:
const http = require('http');

const hostname = '127.0.0.1';


const port = 3000;

const server = http.createServer((req, res) => {


res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});

server.listen(port, hostname, () => {


console.log(`Server running at http://${hostname}:${port}/`);
});
• Run your web server using node app.js. Visit http://localhost:3000 and you will see a message saying "Hello
World".
11
NODE PACKAGE MANAGER (NPM)
• Node.js supports modularity. Each modules can be bundled
under a single package.
• NPM is used to install, update, uninstall and configure Node JS
Platform modules/packages very easily.
INSTALLING THIRD PARTY MODULES
3rd party modules can be downloaded using NPM (Node Package
Manager)
• //Syntax
npm install -g module_name // Install Globally
npm install --save module_name //Install and save in package.json

//Install express module


npm install --save express
npm install --save mongoose

//Install multiple module at once


npm install --save express mongoose
NODE.JS "REQUIRE"
• The modules/packages available can be imported in .js file
using require" funCtiOn.

• Ex — require( "http"); This helps in loading "http" package in


current .js file.
Node Modules
• There are some built-in modules that you can use to create your applications. Some
popular modules are- OS, fs, events, HTTP, URL and then you can include these modules
in your file using these lines-var fs = require('fs');
• Here is an example of how to include an HTTP module to build the server…
• var http = require('http');
• // Create a server object:
• http.createServer(function (req, res) {
• // Write a response to the client
•     res.write(‘hie this is sonel');
•   // End the response 
•     res.end();// The server object listens on port 8080
• }).listen(8080);
MODULES EXPORT AND IMPORT
• Node.js also allows importing and exporting functions and
modules. Functions in one module can be imported and called
in other modules saving the effort to copy function definitions
into the other files. The module can be edited or debugged
separately making it easier to add or remove features.

• For further information-https://www.geeksforgeeks


.org/import-and-export-in-node-js/
• A Node.js application consists of the following three important
components −
• Import required modules − We use the require directive to load
Node.js modules.
• Create server − A server which will listen to client's requests similar to
Apache HTTP Server.
• Read request and return response − The server created in an earlier
step will read the HTTP request made by the client which can be a
browser or a console and return the response.
• REFERENCE-https://www.tutorialspoint.com/nodejs
/nodejs_first_application.htm
Login page
Login page
• https://heynode.com/tutorial/process-user-login-form-expressjs/

You might also like