SlideShare a Scribd company logo
Header
Introduction to Node.js
Course Overview
 What is Node.js?
 Installing Node.js
 Node REPL
 Node Programs
 Managing Packages with NPM
 Building a Simple Web Server
 Reading Files from Disk
 Debugging
 Creating a Package
 Use NPM to run a package
What is Node.js?
 Node.js is a cross-platform, JavaScript environment on the server
 JavaScript is a glue language for C++ modules
 It is powered by Google’s V8 JavaScript engine
 Node.js uses an event driven, non-blocking I/O model
 Node.js is like a web browser with a different set of C++ modules
 It provides modules for interacting with local system resources such as
processes, file system, networking, etc…
Node.js compared to a Web Browser
JavaScript
V8
DOM XHR
Audio
File Reader
Timers
Web
Sockets
Video
Many
More…
JavaScript
V8
File
System
Net
Cluster
HTTP
Timer
Process
Stream
Many
More…
Web Browser Node.js
Installing Node.js
 Node.js can be installed from a platform specific installer, precompiled
source code, and compiled from source code
 To download the installer: http://www.nodejs.org
 When installing using the platform specific installer, most users accept
the defaults
Node.js Versions
 The installer and pre-compiled binaries can be downloaded for either
the Long-Term Support version or Current Version
 Long-Term Support version is best for applications in production
 The Current Version is best for working with the newest features
Node REPL Environment
 REPL stands for Read, Evaluate, Print, Loop
 Allows the user to enter a JavaScript command, evaluate it, print the
results, and loop to enter another command
 Supports multiline commands, customize command prompt and
preconfigured context
 Sessions can be saved, and reloaded again
 Useful for learning JavaScript or executing tasks from a JavaScript
command line
Node.js Programs
 Node.js programs can be created using JavaScript files which are
executed with the Node.js executable
 JavaScript files contain JavaScript programming statements and
expressions, and have a filename extension of ‘.js’
 To execute a Node.js program, run the Node.js executable for the given
environment and pass the name of the file (with or without the JS
extension) as the first argument
Managing Packages with NPM
 NPM is an acronym for Node.js Package Manager
 NPM provides a public package repository, a specification for building
packages, and a command line tool for working with packages
 http://www.npmjs.com
 The company npm, Inc. develops and maintains NPM
 Node.js distributes the npm executable along with the node
executable, but it's actually a separate program with its own versioning
NPM Public Repository
https://www.npmjs.com/
Local vs Global Packages
 Packages can be installed locally or globally
 Local packages are stored locally in a project, in the node_modules
folder
 Global packages are stored globally on system
 Typically, local packages are code libraries used by project
 Typically, global packages are executables used to perform some
operation on a project such as running tasks
 Local packages are available only within their specific project, and
global packages are available system wide
Installing & Uninstalling Packages
 The npm program is used to
manage packages
 The first argument to the npm
program is the command to be
executed
 Packages can be installed with the
install command, and uninstalled
with the uninstall command
 There are many more commands
available for NPM
• The –global flag installs and
uninstalls the package globally,
without the global flag, the
packages are installed and
uninstalled locally
Global Packages on Windows
 Are global to the user,
not the system
 Does not require
administrative privileges
Globally Installed Packages are stored in:
C:Users<username>AppDataRoamingnpm
Global Packages on Mac and Linux
 By default, are global to
the system, not just the
user
 Requires administrative
privileges, unless
permissions are fixed
On a Mac by default, Globally Installed Packages are
stored in:
/usr/local/lib/node_modules
Fixing Permissions for Global Packages
https://docs.npmjs.com/getting-started/fixing-npm-permissions
Building a Simple Web Server
 One of the core modules for Node.js is the HTTP module, which
provides a web server and web client
 The web server is very flexible, but requires a lot of boiler plate coding
to build even the simplest applications
 Web server are I/O intensive applications making them well suited for
Node.js
 Node.js is great for web servers because of its easy handling of JSON
data
Reading Files from Disk
 Node.js allows full access to the system (such as accessing the file
system)
 Accessing file system resources can be synchronously and
asynchronously
 Synchronous access can be used for initial program loading, but only
asynchronous access should be used during program operation
 Both text and binary data can read and written
 Full support for streams
Debugging Node.js
 Node.js comes with a built in command line debugger, but its limited
 Instead, there are many code editors and other tools which greatly
simplify debugging of Node.js applications
 StrongLoop's Node Inspector (free – Windows/Mac/Linux)
 Microsoft Visual Studio Code (free – Windows/Mac/Linux)
 Microsoft Visual Studio with Node.js Extension (community edition free – Windows only)
 GitHub's Atom with Node Debugger Package (free – Windows/Mac/Linux)
 JetBrains' WebStorm (not free – Windows/Mac/Linux)
 These IDEs provide the standard fare of debugging tools such as
breakpoint, call stacks, watches, and local variables
StrongLoop's Node Inspector
https://github.com/node-inspector/node-inspector
Microsoft's Visual Studio Code
https://code.visualstudio.com
Microsoft's Visual Studio with Node.js Extension
https://www.visualstudio.com/products/visual-studio-community-vs
GitHub's Atom with the Node Debugger Package
https://atom.io
JetBrains' WebStorm
https://www.jetbrains.com/webstorm
Creating a Package
 All projects (which are also packages) need to be configured to work
with NPM
 The command npm init is used to configure a project
 It will ask a series of questions, all of which have default answers, that
are used to create and initialize a package.json file
 The package.json file contains metadata about the project, as well as,
a list of application and development dependencies
 When NPM packages are installed, NPM will register them with the
package.json file
Saving Package Dependencies
 Simply installing packages do not save the dependency in the
package.json file
 In addition to installing, additional flags need to be specified:
 --save or -S will save the package as an application dependency
 --save-dev or -D will save the package a development dependency
 Application dependencies are used by the Node.js program when
executing (common example would be Express)
 Development dependencies are used to develop the Node.js program
(common example would be Grunt)
Saving Package Dependencies
• The terminal commands to left, will
produce a package.json file similar to
the one on the right.
• The file is a JSON file, and can be edited
by hand
• Name is the name of the package
• Version follows the SEMVER scheme
• The version of each dependency is
tracked as well
• Main is the main file imported when
requiring the module
Terminal Commands Package.json
Use NPM to run a package
 In addition to managing packages with NPM,
packages can be configured to be executed
with NPM
 To configure the execution of Node packages,
the scripts option of the package.json is
configured
 To run a Node.js program, the start script is
configured
Conclusion
 Node.js is a great platform building applications, especially
applications which are I/O intensive
 Working with Node.js involves many tools for managing packages,
debugging code, and packaging projects for deployment
 The Node Package Manager (NPM) is used to install packages, and
divide applications into smaller reusable parts
 Node.js can be used for development tooling, web applications and
general purpose applications

More Related Content

PPTX
Mastering node.js, part 1 - introduction
cNguyn826690
 
PPTX
Overview of Node JS
Jacob Nelson
 
DOCX
unit 2 of Full stack web development subject
JeneferAlan1
 
PDF
Node JS - A brief overview on building real-time web applications
Expeed Software
 
PPTX
Basics of Node.js
Alper Unal
 
PPTX
Server Side Web Development Unit 1 of Nodejs.pptx
sneha852132
 
PPTX
Basic Concept of Node.js & NPM
Bhargav Anadkat
 
Mastering node.js, part 1 - introduction
cNguyn826690
 
Overview of Node JS
Jacob Nelson
 
unit 2 of Full stack web development subject
JeneferAlan1
 
Node JS - A brief overview on building real-time web applications
Expeed Software
 
Basics of Node.js
Alper Unal
 
Server Side Web Development Unit 1 of Nodejs.pptx
sneha852132
 
Basic Concept of Node.js & NPM
Bhargav Anadkat
 

Similar to Introduction to NodeJS JSX is an extended Javascript based language used by React.js JSX enables writing html tags within javascript functions (20)

PDF
🚀 Node.js Simplified – A Visual Guide for Beginners!
Tpoint Tech Blog
 
PPTX
Node js meetup
Ansuman Roy
 
PPTX
Halton Software Peer 2 Peer Meetup #10
David Ashton
 
PDF
Server Side Apocalypse, JS
Md. Sohel Rana
 
PPTX
Intro to Node.js (v1)
Chris Cowan
 
PDF
Nodejs vatsal shah
Vatsal N Shah
 
PDF
Node js (runtime environment + js library) platform
Sreenivas Kappala
 
PDF
Introduction to Node js for beginners + game project
Laurence Svekis ✔
 
PPTX
Introduction to node.js By Ahmed Assaf
Ahmed Assaf
 
PDF
Node js
Rohan Chandane
 
PPTX
Nodejs
dssprakash
 
PDF
Getting Started with Node.js
Justin Reock
 
KEY
Dcjq node.js presentation
async_io
 
KEY
Nodeconf npm 2011
Florent Jaby ヅ
 
PPTX
node_js.pptx
dipen55
 
PPTX
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
PPTX
JS & NodeJS - An Introduction
Nirvanic Labs
 
PDF
Book
luis_lmro
 
PDF
NodeJS for Beginner
Apaichon Punopas
 
PDF
Steps to Install NPM and Node.js on Windows and MAC
Inexture Solutions
 
🚀 Node.js Simplified – A Visual Guide for Beginners!
Tpoint Tech Blog
 
Node js meetup
Ansuman Roy
 
Halton Software Peer 2 Peer Meetup #10
David Ashton
 
Server Side Apocalypse, JS
Md. Sohel Rana
 
Intro to Node.js (v1)
Chris Cowan
 
Nodejs vatsal shah
Vatsal N Shah
 
Node js (runtime environment + js library) platform
Sreenivas Kappala
 
Introduction to Node js for beginners + game project
Laurence Svekis ✔
 
Introduction to node.js By Ahmed Assaf
Ahmed Assaf
 
Nodejs
dssprakash
 
Getting Started with Node.js
Justin Reock
 
Dcjq node.js presentation
async_io
 
Nodeconf npm 2011
Florent Jaby ヅ
 
node_js.pptx
dipen55
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
JS & NodeJS - An Introduction
Nirvanic Labs
 
Book
luis_lmro
 
NodeJS for Beginner
Apaichon Punopas
 
Steps to Install NPM and Node.js on Windows and MAC
Inexture Solutions
 
Ad

More from JEEVANANTHAMG6 (9)

PPTX
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
JEEVANANTHAMG6
 
PPTX
7. Input Output Operations.pptx
JEEVANANTHAMG6
 
PPTX
MIPS IMPLEMENTATION.pptx
JEEVANANTHAMG6
 
PPTX
EITK UNIT - III.pptx
JEEVANANTHAMG6
 
PPTX
CLEAN CODING AND DEVOPS Final.pptx
JEEVANANTHAMG6
 
PPT
UNIT I.ppt
JEEVANANTHAMG6
 
PPT
Arithmetic for Computers.ppt
JEEVANANTHAMG6
 
PPTX
6. Addressng Modes.pptx
JEEVANANTHAMG6
 
PPT
1.Basic Structure of Computer System.ppt
JEEVANANTHAMG6
 
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
JEEVANANTHAMG6
 
7. Input Output Operations.pptx
JEEVANANTHAMG6
 
MIPS IMPLEMENTATION.pptx
JEEVANANTHAMG6
 
EITK UNIT - III.pptx
JEEVANANTHAMG6
 
CLEAN CODING AND DEVOPS Final.pptx
JEEVANANTHAMG6
 
UNIT I.ppt
JEEVANANTHAMG6
 
Arithmetic for Computers.ppt
JEEVANANTHAMG6
 
6. Addressng Modes.pptx
JEEVANANTHAMG6
 
1.Basic Structure of Computer System.ppt
JEEVANANTHAMG6
 
Ad

Recently uploaded (20)

PDF
B.Tech Data Science Program (Industry Integrated ) Syllabus
rvray078
 
PPTX
Production of bioplastic from fruit peels.pptx
alwingeorgealwingeor
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PPTX
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
PPTX
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PDF
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
PPTX
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
dodultrongaming
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PDF
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
PDF
Activated Carbon for Water and Wastewater Treatment_ Integration of Adsorptio...
EmilianoRodriguezTll
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PPTX
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
PPTX
Azure-DevOps-Training presentation downloadable
NamanGoyal428595
 
PDF
Software Testing Tools - names and explanation
shruti533256
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
B.Tech Data Science Program (Industry Integrated ) Syllabus
rvray078
 
Production of bioplastic from fruit peels.pptx
alwingeorgealwingeor
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
dodultrongaming
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
Activated Carbon for Water and Wastewater Treatment_ Integration of Adsorptio...
EmilianoRodriguezTll
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
Azure-DevOps-Training presentation downloadable
NamanGoyal428595
 
Software Testing Tools - names and explanation
shruti533256
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 

Introduction to NodeJS JSX is an extended Javascript based language used by React.js JSX enables writing html tags within javascript functions

  • 2. Course Overview  What is Node.js?  Installing Node.js  Node REPL  Node Programs  Managing Packages with NPM  Building a Simple Web Server  Reading Files from Disk  Debugging  Creating a Package  Use NPM to run a package
  • 3. What is Node.js?  Node.js is a cross-platform, JavaScript environment on the server  JavaScript is a glue language for C++ modules  It is powered by Google’s V8 JavaScript engine  Node.js uses an event driven, non-blocking I/O model  Node.js is like a web browser with a different set of C++ modules  It provides modules for interacting with local system resources such as processes, file system, networking, etc…
  • 4. Node.js compared to a Web Browser JavaScript V8 DOM XHR Audio File Reader Timers Web Sockets Video Many More… JavaScript V8 File System Net Cluster HTTP Timer Process Stream Many More… Web Browser Node.js
  • 5. Installing Node.js  Node.js can be installed from a platform specific installer, precompiled source code, and compiled from source code  To download the installer: http://www.nodejs.org  When installing using the platform specific installer, most users accept the defaults
  • 6. Node.js Versions  The installer and pre-compiled binaries can be downloaded for either the Long-Term Support version or Current Version  Long-Term Support version is best for applications in production  The Current Version is best for working with the newest features
  • 7. Node REPL Environment  REPL stands for Read, Evaluate, Print, Loop  Allows the user to enter a JavaScript command, evaluate it, print the results, and loop to enter another command  Supports multiline commands, customize command prompt and preconfigured context  Sessions can be saved, and reloaded again  Useful for learning JavaScript or executing tasks from a JavaScript command line
  • 8. Node.js Programs  Node.js programs can be created using JavaScript files which are executed with the Node.js executable  JavaScript files contain JavaScript programming statements and expressions, and have a filename extension of ‘.js’  To execute a Node.js program, run the Node.js executable for the given environment and pass the name of the file (with or without the JS extension) as the first argument
  • 9. Managing Packages with NPM  NPM is an acronym for Node.js Package Manager  NPM provides a public package repository, a specification for building packages, and a command line tool for working with packages  http://www.npmjs.com  The company npm, Inc. develops and maintains NPM  Node.js distributes the npm executable along with the node executable, but it's actually a separate program with its own versioning
  • 11. Local vs Global Packages  Packages can be installed locally or globally  Local packages are stored locally in a project, in the node_modules folder  Global packages are stored globally on system  Typically, local packages are code libraries used by project  Typically, global packages are executables used to perform some operation on a project such as running tasks  Local packages are available only within their specific project, and global packages are available system wide
  • 12. Installing & Uninstalling Packages  The npm program is used to manage packages  The first argument to the npm program is the command to be executed  Packages can be installed with the install command, and uninstalled with the uninstall command  There are many more commands available for NPM • The –global flag installs and uninstalls the package globally, without the global flag, the packages are installed and uninstalled locally
  • 13. Global Packages on Windows  Are global to the user, not the system  Does not require administrative privileges Globally Installed Packages are stored in: C:Users<username>AppDataRoamingnpm
  • 14. Global Packages on Mac and Linux  By default, are global to the system, not just the user  Requires administrative privileges, unless permissions are fixed On a Mac by default, Globally Installed Packages are stored in: /usr/local/lib/node_modules
  • 15. Fixing Permissions for Global Packages https://docs.npmjs.com/getting-started/fixing-npm-permissions
  • 16. Building a Simple Web Server  One of the core modules for Node.js is the HTTP module, which provides a web server and web client  The web server is very flexible, but requires a lot of boiler plate coding to build even the simplest applications  Web server are I/O intensive applications making them well suited for Node.js  Node.js is great for web servers because of its easy handling of JSON data
  • 17. Reading Files from Disk  Node.js allows full access to the system (such as accessing the file system)  Accessing file system resources can be synchronously and asynchronously  Synchronous access can be used for initial program loading, but only asynchronous access should be used during program operation  Both text and binary data can read and written  Full support for streams
  • 18. Debugging Node.js  Node.js comes with a built in command line debugger, but its limited  Instead, there are many code editors and other tools which greatly simplify debugging of Node.js applications  StrongLoop's Node Inspector (free – Windows/Mac/Linux)  Microsoft Visual Studio Code (free – Windows/Mac/Linux)  Microsoft Visual Studio with Node.js Extension (community edition free – Windows only)  GitHub's Atom with Node Debugger Package (free – Windows/Mac/Linux)  JetBrains' WebStorm (not free – Windows/Mac/Linux)  These IDEs provide the standard fare of debugging tools such as breakpoint, call stacks, watches, and local variables
  • 20. Microsoft's Visual Studio Code https://code.visualstudio.com
  • 21. Microsoft's Visual Studio with Node.js Extension https://www.visualstudio.com/products/visual-studio-community-vs
  • 22. GitHub's Atom with the Node Debugger Package https://atom.io
  • 24. Creating a Package  All projects (which are also packages) need to be configured to work with NPM  The command npm init is used to configure a project  It will ask a series of questions, all of which have default answers, that are used to create and initialize a package.json file  The package.json file contains metadata about the project, as well as, a list of application and development dependencies  When NPM packages are installed, NPM will register them with the package.json file
  • 25. Saving Package Dependencies  Simply installing packages do not save the dependency in the package.json file  In addition to installing, additional flags need to be specified:  --save or -S will save the package as an application dependency  --save-dev or -D will save the package a development dependency  Application dependencies are used by the Node.js program when executing (common example would be Express)  Development dependencies are used to develop the Node.js program (common example would be Grunt)
  • 26. Saving Package Dependencies • The terminal commands to left, will produce a package.json file similar to the one on the right. • The file is a JSON file, and can be edited by hand • Name is the name of the package • Version follows the SEMVER scheme • The version of each dependency is tracked as well • Main is the main file imported when requiring the module Terminal Commands Package.json
  • 27. Use NPM to run a package  In addition to managing packages with NPM, packages can be configured to be executed with NPM  To configure the execution of Node packages, the scripts option of the package.json is configured  To run a Node.js program, the start script is configured
  • 28. Conclusion  Node.js is a great platform building applications, especially applications which are I/O intensive  Working with Node.js involves many tools for managing packages, debugging code, and packaging projects for deployment  The Node Package Manager (NPM) is used to install packages, and divide applications into smaller reusable parts  Node.js can be used for development tooling, web applications and general purpose applications