NODEjs lecture 1
NODEjs lecture 1
Introduction
Jalpa Mehta
Assistant Professor
SAKEC,Chembur
Module:5
• Contents
Environment set up
• First App
• Asynchronous Programming
• Call back concept
• Event loops
• REPL
• Event Emitter
• Networking Module
• Buffers
• Streams
• File Systems
• Web Modules
• Node.js with mongodb
Full stack JavaScript tools
• Using Node.js for backend, you automatically get all the pros
of full stack JavaScript development, such as:
• better efficiency and overall developer productivity
• code sharing and reuse
• speed and performance
• easy knowledge sharing within a team
• a huge number of free tools
Environment Set UP
• If you want to set up your environment for Node.js, you need to have the
following two software on your computer,
(a)Text Editor : Examples of text editors include Windows Notepad, OS Edit
command, Brief, Epsilon, EMACS, and vim or vi.
Use Variables
You can make use variables to store values and print later like any
conventional script. If var keyword is not used, then the value is
stored in the variable and printed.
Whereas if var keyword is used, then the value is stored but not
printed. You can print variables using
console.log()
• > node
> x = 10
10
> var y = 10
undefined
>x+y
20
> console.log("Hello World")
Hello World
undefined
Multiline Expression
Node REPL supports multiline expression similar to JavaScript. Let's
check the following dowhile loop in action:
> node
> var x = 0
undefined
> do {
... x++;
... console.log("x: " + x);
... } while ( x < 5 );
x: 1
x: 2
x: 3
x: 4
x: 5
undefined
>
NODe.js package
Manager(NPM)
• Node Package Manager (NPM) provides two main
functionalities −
• Online repositories for node.js packages/modules which are
searchable on search.nodejs.org
• Command line utility to install Node.js packages, do version
management and dependency management of Node.js
packages.
•$ npm -- version
Parts of node.js