SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
Node JS
QUICK START TRAINING
Table of Content:
● About Node Js
● How to install Node JS
● About NPM
● npm init
● Node Scheduler and Http Request
● Socket.io
● Express Js Framework
● Monitor Live status of APP thorough PM2
● Deployment
About Node Js:-
● Node.js is an open source server environment
● Node.js is free
● Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
● Node.js uses JavaScript on the server
● Node.js eliminates the waiting, and simply continues with the next request.
● Node.js runs single-threaded, non-blocking, asynchronous programming, which is very memory
efficient.
● Node.js can generate dynamic page content
● Node.js can create, open, read, write, delete, and close files on the server
● Node.js can collect form data Node.js can add, delete, modify data in your database
How to install Node JS:-
1. Open the official page for Node.js downloads and download Node.js for Windows by clicking the
"Windows Installer" option
2. Run the downloaded Node.js .msi Installer - including accepting the license, selecting the
destination, and authenticating for the install (This requires Administrator privileges, and you may
need to authenticate)
3. To ensure Node.js has been installed, run node -v in your terminal - you should get something like
v6.9.5.
4. Congratulations - you've now got Node.js installed, and are ready to start building!
5. As the final step in getting Node.js installed, we'll update your version of npm - the package manager
that comes bundled with Node.js. npm install npm --global // Update the `npm` CLI client
On Ubuntu:-
sudo apt install nodejs
npm -v or npm –version
About NPM:-
What is NPM?NPM is a package manager for Node.js packages, or modules if you like. www.npmjs.com
hosts thousands of free packages to download and use. The NPM program is installed on your computer
when you install Node.js
What is a Package? A package in Node.js contains all the files you need for a module. Modules are
JavaScript libraries you can include in your project.
Download a Package
Downloading a package is very easy. Open the command line interface and tell NPM to download the
package you want. I want to download a package called "upper-case":
C:UsersYour Name>npm install upper-case
Command:npm init
package name: (mycode) testpackage-ashish
version: (1.0.0) 1.0.0
description: Project Description
entry point: (index.js) app.js
test command:
git repository: git@gitlab.com:ashishinvetech/testpackage-ashish.git
keywords: testpackage-ashish
author: Ashish Gupta
license: (ISC)
Is this OK? (yes) yes
npm login
npm publish
npm publish --access public
How to Initialize nodejs app and publish own module
● Http Request
var http = require('https');
var optionsgetmsg = {
hostname: 'portal.hpsldc.com',
port: 443,
path: '/app/api/index.php/importrtmiexftp',
method: 'GET'
};
var reqGet = http.request(optionsgetmsg, function (res) {
res.on('data', function (d) {
myData += d.toString();
});
res.on('end', function (d) {
console.log(myData);
});
});
reqGet.end();
reqGet.on('error', function (e) {
console.error(e);
});
● Node Scheduler and Http Request
Install node-cron using npm:
$ npm install --save node-cron
Import node-cron and schedule a task:
var cron = require('node-cron')
cron.schedule('* * * * *', () => {
console.log('running a task every
minute');
});
# ┌────────────── second (optional)
# │ ┌──────────── minute
# │ │ ┌────────── hour
# │ │ │ ┌──────── day of month
# │ │ │ │ ┌────── month
# │ │ │ │ │ ┌──── day of week
# │ │ │ │ │ │
# │ │ │ │ │ │
# * * * * * *
● Express JS
Fast, unopinionated, minimalist web framework for Node.js
$ npm install express --save
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
res.sendFile(__dirname + '/index.html');
})
app.post('/', function (req, res) {
res.send('Got a POST request')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
Serving static files in Express
app.use('/static', express.static('public'))
http://localhost:3000/static/images/kitten.jpg
The app.locals object has properties that are local
variables within the application.
● Socket.io
npm install socket.io
var app = require('express')();
var http = require('http').createServer(app);
var io = require('socket.io')(http);
app.get('/', (req, res) => {
res.sendFile(__dirname + '/index.html');
});
io.on('connection', (socket) => {
console.log("some one connected");
socket.on('chat message', (msg) => {
console.log(msg);
io.emit('chat message', msg);
});
});
http.listen(3000, () => {
console.log('listening on *:3000');
});
More Detail:-https://socket.io/get-started/
● PM2
1. ADVANCED, PRODUCTION PROCESS MANAGER FOR NODE.JS
2. PM2 is a daemon process manager that will help you manage and keep your application online 24/7
npm install pm2@latest -g
pm2 start app.js
pm2 monit
pm2 monit
pm2 list
pm2 stop
pm2 restart
pm2 delete
Ref:https://pm2.keymetrics.io/docs/usage/pm2-doc-single-page/
● Deployment
1. Git Clone /pull in server directory
2. npm install to install all dependency
3. pm2 start startpage.js
For multiple virtual host
https://www.digitalocean.com/community/questions/setting-up-multiple-nodejs-applications-using-
nginx-vitual-hosts
Thank You

More Related Content

What's hot (20)

PDF
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
Nurul Ferdous
 
PPTX
NodeJS - Server Side JS
Ganesh Kondal
 
PDF
Introduction to node js - From "hello world" to deploying on azure
Colin Mackay
 
PDF
Introduction to REST API with Node.js
Yoann Gotthilf
 
PDF
Node JS Express: Steps to Create Restful Web App
Edureka!
 
PDF
Nodejs
Prem Sanil
 
PPTX
Node js for enterprise
ravisankar munusamy
 
PPTX
Introduction to node.js
Arun Kumar Arjunan
 
PPTX
Introduction to Node.js
Vikash Singh
 
PPTX
Introduction to node.js GDD
Sudar Muthu
 
PPT
Introduction to node.js aka NodeJS
JITENDRA KUMAR PATEL
 
PDF
Nodejs presentation
Arvind Devaraj
 
PDF
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
Edureka!
 
PDF
Node, express & sails
Brian Shannon
 
PPTX
Introduction to Node js
Pragnesh Vaghela
 
PPTX
A slightly advanced introduction to node.js
Sudar Muthu
 
PPTX
Introduction to node.js by jiban
Jibanananda Sana
 
PDF
Introduction to Node.js
Rob O'Doherty
 
PPTX
Introduction to Node.js
Winston Hsieh
 
PPTX
Starting with Node.js
Jitendra Zaa
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
Nurul Ferdous
 
NodeJS - Server Side JS
Ganesh Kondal
 
Introduction to node js - From "hello world" to deploying on azure
Colin Mackay
 
Introduction to REST API with Node.js
Yoann Gotthilf
 
Node JS Express: Steps to Create Restful Web App
Edureka!
 
Nodejs
Prem Sanil
 
Node js for enterprise
ravisankar munusamy
 
Introduction to node.js
Arun Kumar Arjunan
 
Introduction to Node.js
Vikash Singh
 
Introduction to node.js GDD
Sudar Muthu
 
Introduction to node.js aka NodeJS
JITENDRA KUMAR PATEL
 
Nodejs presentation
Arvind Devaraj
 
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
Edureka!
 
Node, express & sails
Brian Shannon
 
Introduction to Node js
Pragnesh Vaghela
 
A slightly advanced introduction to node.js
Sudar Muthu
 
Introduction to node.js by jiban
Jibanananda Sana
 
Introduction to Node.js
Rob O'Doherty
 
Introduction to Node.js
Winston Hsieh
 
Starting with Node.js
Jitendra Zaa
 

Similar to Node js training (1) (20)

PDF
Node intro
Vishal Sharma
 
DOCX
unit 2 of Full stack web development subject
JeneferAlan1
 
PPTX
Basic Concept of Node.js & NPM
Bhargav Anadkat
 
PDF
🚀 Node.js Simplified – A Visual Guide for Beginners!
Tpoint Tech Blog
 
PPTX
Intro to Node.js (v1)
Chris Cowan
 
PPTX
3 Things Everyone Knows About Node JS That You Don't
F5 Buddy
 
PDF
Nodejs vatsal shah
Vatsal N Shah
 
PPTX
Introduction to node.js By Ahmed Assaf
Ahmed Assaf
 
PPTX
Server Side Web Development Unit 1 of Nodejs.pptx
sneha852132
 
PDF
Node js
Rohan Chandane
 
KEY
Node.js - The New, New Hotness
Daniel Shaw
 
PPTX
Overview of Node JS
Jacob Nelson
 
PDF
NodeJS for Beginner
Apaichon Punopas
 
PPTX
Nodejs
dssprakash
 
PDF
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
OdessaFrontend
 
PDF
Node.js for beginner
Sarunyhot Suwannachoti
 
PDF
What is Node.js_ Where, When & How To Use It.pdf
Smith Daniel
 
PDF
Node JS - A brief overview on building real-time web applications
Expeed Software
 
PDF
Node.js Course 1 of 2 - Introduction and first steps
Manuel Eusebio de Paz Carmona
 
Node intro
Vishal Sharma
 
unit 2 of Full stack web development subject
JeneferAlan1
 
Basic Concept of Node.js & NPM
Bhargav Anadkat
 
🚀 Node.js Simplified – A Visual Guide for Beginners!
Tpoint Tech Blog
 
Intro to Node.js (v1)
Chris Cowan
 
3 Things Everyone Knows About Node JS That You Don't
F5 Buddy
 
Nodejs vatsal shah
Vatsal N Shah
 
Introduction to node.js By Ahmed Assaf
Ahmed Assaf
 
Server Side Web Development Unit 1 of Nodejs.pptx
sneha852132
 
Node.js - The New, New Hotness
Daniel Shaw
 
Overview of Node JS
Jacob Nelson
 
NodeJS for Beginner
Apaichon Punopas
 
Nodejs
dssprakash
 
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
OdessaFrontend
 
Node.js for beginner
Sarunyhot Suwannachoti
 
What is Node.js_ Where, When & How To Use It.pdf
Smith Daniel
 
Node JS - A brief overview on building real-time web applications
Expeed Software
 
Node.js Course 1 of 2 - Introduction and first steps
Manuel Eusebio de Paz Carmona
 
Ad

Recently uploaded (20)

PPTX
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
NSF Converter Simplified: From Complexity to Clarity
Johnsena Crook
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PDF
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
NSF Converter Simplified: From Complexity to Clarity
Johnsena Crook
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
Ad

Node js training (1)

  • 2. Table of Content: ● About Node Js ● How to install Node JS ● About NPM ● npm init ● Node Scheduler and Http Request ● Socket.io ● Express Js Framework ● Monitor Live status of APP thorough PM2 ● Deployment
  • 3. About Node Js:- ● Node.js is an open source server environment ● Node.js is free ● Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.) ● Node.js uses JavaScript on the server ● Node.js eliminates the waiting, and simply continues with the next request. ● Node.js runs single-threaded, non-blocking, asynchronous programming, which is very memory efficient. ● Node.js can generate dynamic page content ● Node.js can create, open, read, write, delete, and close files on the server ● Node.js can collect form data Node.js can add, delete, modify data in your database
  • 4. How to install Node JS:- 1. Open the official page for Node.js downloads and download Node.js for Windows by clicking the "Windows Installer" option 2. Run the downloaded Node.js .msi Installer - including accepting the license, selecting the destination, and authenticating for the install (This requires Administrator privileges, and you may need to authenticate) 3. To ensure Node.js has been installed, run node -v in your terminal - you should get something like v6.9.5. 4. Congratulations - you've now got Node.js installed, and are ready to start building! 5. As the final step in getting Node.js installed, we'll update your version of npm - the package manager that comes bundled with Node.js. npm install npm --global // Update the `npm` CLI client On Ubuntu:- sudo apt install nodejs npm -v or npm –version
  • 5. About NPM:- What is NPM?NPM is a package manager for Node.js packages, or modules if you like. www.npmjs.com hosts thousands of free packages to download and use. The NPM program is installed on your computer when you install Node.js What is a Package? A package in Node.js contains all the files you need for a module. Modules are JavaScript libraries you can include in your project. Download a Package Downloading a package is very easy. Open the command line interface and tell NPM to download the package you want. I want to download a package called "upper-case": C:UsersYour Name>npm install upper-case
  • 6. Command:npm init package name: (mycode) testpackage-ashish version: (1.0.0) 1.0.0 description: Project Description entry point: (index.js) app.js test command: git repository: [email protected]:ashishinvetech/testpackage-ashish.git keywords: testpackage-ashish author: Ashish Gupta license: (ISC) Is this OK? (yes) yes npm login npm publish npm publish --access public How to Initialize nodejs app and publish own module
  • 7. ● Http Request var http = require('https'); var optionsgetmsg = { hostname: 'portal.hpsldc.com', port: 443, path: '/app/api/index.php/importrtmiexftp', method: 'GET' }; var reqGet = http.request(optionsgetmsg, function (res) { res.on('data', function (d) { myData += d.toString(); }); res.on('end', function (d) { console.log(myData); }); }); reqGet.end(); reqGet.on('error', function (e) { console.error(e); });
  • 8. ● Node Scheduler and Http Request Install node-cron using npm: $ npm install --save node-cron Import node-cron and schedule a task: var cron = require('node-cron') cron.schedule('* * * * *', () => { console.log('running a task every minute'); }); # ┌────────────── second (optional) # │ ┌──────────── minute # │ │ ┌────────── hour # │ │ │ ┌──────── day of month # │ │ │ │ ┌────── month # │ │ │ │ │ ┌──── day of week # │ │ │ │ │ │ # │ │ │ │ │ │ # * * * * * *
  • 9. ● Express JS Fast, unopinionated, minimalist web framework for Node.js $ npm install express --save const express = require('express') const app = express() const port = 3000 app.get('/', (req, res) => { res.send('Hello World!') res.sendFile(__dirname + '/index.html'); }) app.post('/', function (req, res) { res.send('Got a POST request') }) app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`) }) Serving static files in Express app.use('/static', express.static('public')) http://localhost:3000/static/images/kitten.jpg The app.locals object has properties that are local variables within the application.
  • 10. ● Socket.io npm install socket.io var app = require('express')(); var http = require('http').createServer(app); var io = require('socket.io')(http); app.get('/', (req, res) => { res.sendFile(__dirname + '/index.html'); }); io.on('connection', (socket) => { console.log("some one connected"); socket.on('chat message', (msg) => { console.log(msg); io.emit('chat message', msg); }); }); http.listen(3000, () => { console.log('listening on *:3000'); }); More Detail:-https://socket.io/get-started/
  • 11. ● PM2 1. ADVANCED, PRODUCTION PROCESS MANAGER FOR NODE.JS 2. PM2 is a daemon process manager that will help you manage and keep your application online 24/7 npm install pm2@latest -g pm2 start app.js pm2 monit pm2 monit pm2 list pm2 stop pm2 restart pm2 delete Ref:https://pm2.keymetrics.io/docs/usage/pm2-doc-single-page/
  • 12. ● Deployment 1. Git Clone /pull in server directory 2. npm install to install all dependency 3. pm2 start startpage.js For multiple virtual host https://www.digitalocean.com/community/questions/setting-up-multiple-nodejs-applications-using- nginx-vitual-hosts