Posts

Showing posts with the label node

01.Topics

Image
  01.Topics Node – Introduction Node – Download and install. Node – Start With Example.

02.Node – Introduction.

Image
Node – Introduction. Node.js යනු server side application develop කරන්න 2009 develop කල open source cross flat form runtime environment එකකි   (not a framework). Normally JavaScript,   client code run කරන්න   තමා use   කරන්නේ . Node.js මගින් JavaScript server side සමගද   වැඩ කරන්න environment    එක හදල දීම තමා කරන්නේ. Node.js හි විශේෂත්වයන් සැලකීමේදී, එකම   language එකනේ client and server යන side දෙකම handle කරන්න පුළුවන් වේ. අනෙක් servers සමග බලද්දී ඒවා බොහොමයක් multithread වන අතර Node.js Single thread and Asynchronous වේ (Event based not thread based). Node.js applications execute වෙන්නේ Google chrome browser එක පවා බාවිතා කරන V8 JavaScript engine එකක වේ . Node.js   වැදගත් ඇයි ( What is the Importance to learn Node.js ) It is fast. It can handle tons of concurrent request. It is written in JavaScript (which means we can use same code server side and client side)

02.Node – Download and install.

Image
  Node – Download and install. Go to https://nodejs.org/en/ and download a LTS (long terms service) or Current version. I select here is How to check whether node js install or not open the comment prompt and type node –v   and enter.   How to check whether npm (Node Package Manager) install or not open the comment prompt and type   npm –v and enter. (Node package manager should be install because it is very important to build node application.When you install the node, npm also automatically get installed.)

03.Node – Start With Example.

Image
Node – Start With Example. Steps, Make a folder – mkdir   folderName  (my folder name is nodeExample) Go to indide the folder – cd nodeExample Create a javaScript file inside nodeExample folder – example.js Copy and paste bellow code and save. Run js file (server).   D:\OTHER\nodeExample\node example.js 1st Example const   http  =  require ( 'http' ); const   hostname  =  '127.0.0.1' ; const   port  =  3000 ; const   server  =  http . createServer (( req ,  res )  =>  {    //res.writeHead(200,{'Content-Type' : 'text/plain'});    res . statusCode  =  200 ;    res . setHeader ( 'Content-Type' ,  'text/plain' );    res . end ( 'Hello World \n ' ); }); server . listen ( port ,  hostname , ()  =>  {    console . log ( `Server running at http:// ${ hostname } : ${ port } /` ); });...