Jump Start Node.js

GitHub link

Node.js is a Server-side framework, useful for building highly scalable and fast applications. It used to run only in browsers a few years ago. JavaScript and server-side languages such as Java, C#, Ruby, Python, PHP and the like are used in Web development.

  • History of Node.js
  • Node.js Overview
  • Node.js uses benefits and applications
  • Node.js main features
  • Installation Steps
  • Running Node.js server
  • Who Use Node.js

History of Node.js

Node.js was developed by Ryan Dahl at Joyent, Inc. in 2009. Ryan was interested in developing Network Applications. It was first released in 2009 and used to support only Linux. Node.js version 0.1.0 and the Windows version was released in 2011.

Node.js Overview

Node.js is a server side JavaScript environment to develop Web Applications like Full Stack, Mean Stack and open-source and cross-platform framework. Node.js, or simply Node, is written in C++ and JavaScript.

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight, efficient and perfect for data-intensive real-time applications that run across distributed devices.

Node.js is made up of three things

  1. Chrome's V8 JavaScript engine (V8)
  2. Thread pool (Libeio)
  3. Event loop (Libev)

Node.js uses benefits and applications

  • Real time Data intensive.
    Ex - Multiplayer Games, Stock Trading, Chat App etc.
  • Highly scalable servers for Web Applications.
    Ex - E-Commerce, Social Media, REST API etc.
  • Builds fast and scalable network Applications.
    Ex - Proxy Server, Backend web services, HTTP Web Server etc.

Node.js main features (Node.js v6)

  • Node.js version 6 focuses on performance improvements, increased reliability and better security for its 3.5 million users.

  • Node.js is emerging as a universal platform used for Web Applications, IoT, mobile, Enterprise Application development and micro service architectures.

  • Full stack JavaScript developers can use for front end, back end, mobile and IoT projects.

  • Node.js v6 comes equipped with v8 JavaScript engine 5.0, which has improved ECMAScript 2015 (ES6) support. Ninety-three percent of ES6 features are also now supported in the Node.js v6 release.

Installation Steps

Installing Node and NPM is pretty straightforward using the installer package available from the Node.js web site.

node

Node.js Setup Wizard on Windows

Setup

Setup

Setup

Default options for Node.js installer on Windows

options

options

options

options

Now, check Node.js is installed successfully and it will look like this in Windows 10, as shown below:

windows 10

Running Node.js from the command line

command

Next, now check node & npm version. Node.js command will prompt to write text, as shown below:

command

Running Node.js server

IDE used for WebStorm JavaScript IDE WebStorm Node.js Support

Create a new project using "File" -> "New" -> "Project..." then select Empty " Location. Name it “Test server".

New

Now, New -> The app folder has scripts.

New

Now, Add New JavaScript file Name -> Server.js -> OK.

Add

Add

Run a script file in Node.js from WebStorm.

script

The output Node Server is running as shown:

output

Now run the page and it will look as shown:

page

Let's create a file called server.js and put the code shown below inside.

  1. /** 
  2.  * Created by Sanjay on 5/19/2016. 
  3.  */  
  4. var http = require('http');  
  5. http.createServer(function(req, res)  
  6. {  
  7.     res.writeHead(200,   
  8.     {  
  9.         'Content-Type''text/plain'  
  10.     });  
  11.     res.end('Hello World\n');  
  12. })  
  13. .listen(9000, '127.0.0.1');  
  14. console.log('Server running at http://127.0.0.1:9000/');  
Who Uses Node.js?

Node.js is used by tens of thousands of organizations in more than 200 countries and amasses more than 3.5 million active users per month.

The Foundation is made up of a diverse group of companies including Platinum Members Famous, IBM, Intel, Joyent, Microsoft, PayPal and Red Hat. Gold members include GoDaddy, NodeSource and Modulus/Progress Software and Silver members include Apigee, AppDynamics, Codefresh, DigitalOcean, Fidelity, Google, Groupon, nearForm, New Relic, npm, Opbeat, RisingStack, Sauce Labs, SAP, StrongLoop (an IBM company), Sphinx, YLD!, and Yahoo!. Get involved here.

 

Up Next
    Ebook Download
    View all
    Learn
    View all