Node js Intro

Intro

  • Node js is javascript on your backend servers.
  • Execution of js on the server is not done by node. It is done with a virtual machine(v8 or chakra). Node is just the coordinator who instructs the v8 or chakra to execute the js code.
  • So its a wrapper around the VM. The default VM in node is V8
  • Node Js is javascript runtime built on Chrome V8 Engine
    • You dont need browser now. you have taken something out from v8 engine and can run outside the browser
  • Open source
  • It allows to run javascript on the server,
  • Node js can run on multiple OS.
  • Whys it is named as Node ?? We build simple , small single process building blocks, nodes that can be organised with good netowrking protocols to have them communicate with each other and scale up to build large distributed systems.

Installation

  • Installation is straing forward. Download the latest node version from https://nodejs.org/en/download/
  • Node is bit different in windows compared to mac and linux. There might be some problems. So If you have windows system ,Install windows subsytem for linux
    • you will get the benefit of having OS as Windows running linux. This will not make you reboot.
 

PACKAGE MANAGER

Advantages

  • As we know its a wrapper around v8. It has built in modules providing rich features through easy to use asynchronous APIs.
    •  example of built is module like http which we will see later 
    • v8 itself is single threaded. This is true for both node and the browser. you get only single thread to work with.
  • You can do asynchronous programming in Node without worrying about thread. Doesnt block the main execution thread.
  • It has a powerful debugger.
  • NPM – Its a platform for tools.
    • you can install third party packages available in the registry using node. you can npm install the packages available in the registry. Registry is where the packages gets hosted.
    • Even you can push your code to npm which other can download and use it.
  • It has module dependency managers
    • Commonjs modules – (Dependency are manage by require function)
    • Ecmascript modules – (Dependencies are managed with import/export)
 

Leave a Comment