资源描述:
《Master nodejs》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、MasteringNodeNodeisanexcitingnewplatformdevelopedbyRyanDahl,allowingJavaScriptdeveloperstocreateextremelyhighperformanceserversbyleveragingGoogle'sV8JavaScriptengine,andasynchronousI/O.InMasteringNodewewilldiscoverhowtowritehighconcurrencywebservers,utilizingtheCommonJSmodulesys
2、tem,node'scorelibraries,thirdpartymodules,highlevelwebdevelopmentandmore.MasteringNode1InstallingNodeInthischapterwewillbelookingattheinstallationandcompilationofnode.Althoughthereareseveralwayswemayinstallnode,wewillbelookingathomebrew,nDistro,andthemostflexiblemethod,ofcourse-
3、compilingfromsource.HomebrewHomebrewisapackagemanagementsystemforOSXwritteninRuby,isextremelywelladopted,andeasytouse.Toinstallnodeviathebrewexecutablesimplyrun:$brewinstallnode.jsnDistronDistroisadistributiontoolkitfornode,whichallowscreationandinstallationofnodedistroswithinse
4、conds.AnnDistroissimplyadotfilenamed.ndistrowhichdefinesmoduleandnodebinaryversiondependencies.Intheexamplebelowwespecifythenodebinaryversion0.1.102,aswellasseveral3rdpartymodules.node0.1.102modulesenchalabsconnectmodulevisionmediaexpress1.0.0beta2modulevisionmediaconnect-formmo
5、dulevisionmediaconnect-redismodulevisionmediajademodulevisionmediaejsAnymachinethatcanrunashellscriptcaninstalldistributions,andkeepsdependenciesdefinedtoasingledirectorystructure,makingiteasytomaintainandeploy.nDistrousespre-compilednodebinariesmakingthemextremelyfasttoinstall,
6、andmoduletarballswhicharefetchedfromGitHubviawgetorcurl(autodetected).TogetstartedwefirstneedtoinstallnDistroitself,belowwecdtoourbindirectoryofchoice,curltheshellscript,andpipetheresponsetoshwhichwillinstallnDistrotothecurrentdirectory:$cd/usr/local/bin&&curlhttp://github.com/v
7、isionmedia/ndistro/raw/master/install
8、shNextwecanplacethecontentsofourexamplein./.ndistro,andexecutendistrowithnoarguments,promptingtheprogramtoloadtheconfig,andstartinstalling:$ndistroInstallationoftheexampletooklessthan17secondsonmymachine,andoutputsthefollowingstdoutindicatin
9、gsuccess.Notbadforanentirestack!...installingno