What is Node.js Exactly? - A beginners introduction to Nodejs

Node means Server and JS means Java Script so in simple words Node.js is a Server Side Java Script framework which is open source, cross-platform runtime environment for developing server-side and networking applications. We can run Node.js applications within the Node.js runtime on OS X, Microsoft Windows, and Linux.

How does Node.js works?

Let's take a simple example, a program created in a language like PHP or Python depends on a traditional thread based model for client connections. To execute a request each connection creates an Operating System (OS) thread which minimum consume around 2MB system memory so if your application is on the server with 4096MB (4GB) RAM then your server can handle maximum 2048 client connections before exhausting server's memory.
Where as Node.js connection uses a very small amount of memory while connecting due to usage of Event Driven Programming. Then, Node.js uses callbacks or references to inform the OS that a new connection is being requested. So the majority of the time Node.js does not disturb the OS, and this can increase overall performance and efficiency of the server.

Some things you should know about Node.js
  • Node.js is Asynchronous and Event Driven.
  • JavaScript is everywhere which runs across many OS environments.
  • Node.js is fast which can lead to increased performance and efficiency of the server.
  • No or minimal file locking as two or more processes share same resource.
  • Node.js is released under the MIT license.
  • NPM (Node Package Manager) which is repositories for Node.js packages/modules works broadly.
Node.js disadvantages :-
Can't be run on most shared-hosting servers.
Still new and lacks some wider database support.

Node.js installation

Requirements :-

You must have a Virtual Private Server (VPS) or Dedicated Server in order to install Node.js, this can't be install on the shared hosting server.
Root access needed to run commands on the server.
Software dependencies like openssl, Python2.6+ and a compiler like gcc must be installed on the server.

Installing Node.js -
1. Login to your server via root user via SSH.

2. Install Software dependencies like openssl, Python2.6+ and gcc.
   yum install openssl-devel
   yum install python26
   yum install gcc-c++

3. Now, go to your server's source directory - cd /usr/local/src

4. Download the latest copy of Node.js - 
get http://nodejs.org/dist/node-latest.tar.gz

5. Extract the Node.js archive - tar zxvf node-latest.tar.gz

6. Now, go to the Node.js directory - cd node-v*

7. Configure and install Node.js using below commands -
python2.6 configure
make PYTHON=python2.6
make install

8. Finally you can test your Node.js installation by simply calling the node interpreter - 
root@server [~]# node

You should now have a successful installation of Node.js running. :)

Was this answer helpful?

 Print this Article

Also Read

How to perform LAMP installation on CentOS?

LAMP stands for Linux, Apache, MySQL, and PHP. It is nothing but Linux operating system with...

How to install Imagic?

1. # yum install ImageM* netpbm gd gd-* libjpeg libexif gcc coreutils make 2.  # cd...

How to update kernel on centos server?

Please follow below steps to update the kernel on centos server - 1. SSH of centos server and...

Basic exim commands

1. REMOVE MAILS BY ID - /usr/sbin/exim -v -Mrm (MAIL ID HERE) 2. LIST QUEUED MAILS -...

How to fix Amazon S3-RequestTimeTooSkewed?

If you have configured a Amazon S3 backup server under cPanl backup configuration to upload...

Powered by WHMCompleteSolution