Sunday, 1 July 2018

Node js Basics




What is Node js?

NodeJS is an open source, cross platform java Script run time environment used to develop server side java Script based applications. Nodejs can be used to develop a fullStack (both back end and front end) in  same language. It was Developed by Ryan Dahl. NodeJS comes with several JavaScript libraries that help basic programming.Node JS is most suitable for data-intensive real time applications(i.e it is ideal for I/O heavy applications).But this is not suitable for CPU intensive applications.It is single threaded and uses non-blocking I/O model.(i.e Node js handles multiple i/o requests asynchronously using the event-loop)

Node JS eco-system ‘npm’ is the largest in the world for open source libraries.

What is NPM?

It is the Node Package Manager. Node.js has an npm registry ,which has a lot of packages. It  will check the online repositories  for node js modules and install them to Node js.It will further do version mangement and dependancy management of the installed packages.By default all the dependencies will get installed to ‘node_modules’ directory.These moules can be installed globally or locally.By default, NPM installs any dependency in the local scope.Global installations will be available throughout the system while local installations will only be available for that particular application.

Package.json

package.json is present in the root directory of any Node application/module.It define s the properties of a package. package.json’ will contain name, version, author, repository, required node version, scripts and dependencies etc