NodeJSBackEnd Programming Node JS 

Getting Started With NodeJS

The world of Web development is segregated as Front-End and the Back-End. Server-side scripting, a technique used in web development that employs scripts on a web server producing a response customized for each user’s (client’s) request to the website. There are a number of server-side scripting languages available – ASP.NET, Java, Python, Perl, PHP, NodeJS, etc. In fact, Node is one of the most popular server side scripting languages in recent times with large scale companies implementing it.

Node.js

Node JS is an open-source, cross-platform JavaScript run-time environment for executing JavaScript code server-side. It is a JavaScript runtime built on Chrome’s V8 JavaScript engine. It uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world. Node.js was developed by Ryan Dahl in 2009.

Furthermore, it provides a rich library of various JavaScript modules which simplifies the development of web applications using Node.js to a great extent.

Node.js = Runtime Environment + JavaScript Library

 

Environment Required

The environment required to run Node,

  1. A Text Editor (Notepad++, Sublime Text, etc)
  2. Node.js binary files

Once the installation is complete, type the below command on the command prompt.

node -v

This command gives the current version of NodeJs installed on the machine.

Hello, World!

The first program written on all programming platform begins with the ‘Hello, World!‘, and we follow the same.

var http = require('http'); //We use the required directive to load the http module.

//Create a server
var server = http.createServer(function(req, res) {
  res.writeHead(200);   
  res.end('Hello, World!'); //Display Text
});
server.listen(5000);  //bind it at port 5000

To execute the code,

node helloworld.js

Click on the browser, type http://localhost:5000/ and hit enter.

Also Read:  Stored Procedure Vs Function in MS SQL Server

Hello World

NPM – Node Package Manager

npm is the package manager for JavaScript and the world’s largest software registry.

  • Online repositories for node.js packages/modules on search.nodejs.org
  • Command line utility to install Node.js packages.

After the V0.6.3, the npm comes bundled in with NodeJs installable files.

To verify the version of NPM, type,

npm --version

 

To install an NPM module, type,

npm install <module name>

Related posts