Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Node.JSNode.jsisanopensource,cross-platform,JavaScriptruntimebuiltonChrome'sV8JavaScriptengine,fordevelopingserverandclientsideapplications.Node.jsusesanevent-driven,non-blockingI/Omodelthatmakesitlightweightandefficient.
Node’sgoalistoprovideaneasywaytobuildscalablenetworkprograms
Install Node.jsFrom
http://nodejs.org
ConsoleUse
ExitConsole
RunFile
LoadFile
Non-Blocking
REQUESTS
EVENT LOOP(single thread)
EXPENSIVEOPERATION
FILE SYSTEM
DATABASE
COMPUTATION
ArchitecturalShift1.old) webserverwithapplicationlogic1.new) appthatcanconnectandcollaborate
2.old) stateful2.new) stateless
ArchitecturalShift1.old) blocking1.new) non-blocking
2.old) processperrequest2.new) singleprocess
MODULES
Packagemanager.Installs,publishesandmanagesnodeprograms
Whatisnpm?
https://www.npm
js.com
Whatisnpm?LargestEcosystem
475KModules2.7Billion/Week
Advantages• Smallpieces,looselyjoined• Leverageexternalpackages• Leverageinternalpackages• Facilitatecollaboration• Packagesarediscoverableinnpm
WhatisaModule?AModuleissomeJavaScriptpairedwithapackage.jsonfile
+
Make module with “module.exports”
Use module with “require”
Creatingnode/npmapps
“npm init” generates the configuration file package.json
addingnpmpackagestoyourapplication
Local installation of request package. Dependency added to package.json
ActiveLearning• …