Saturday, 2 March 2013

Beginners Guide : How to Install Node.js


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



In simple words – is server-side JavaScript. Every function in Node.js is asynchronous,Node.js uses an event-based server execution procedure rather than the multithreaded execution in PHP.

Node.js provide only an environment – meaning that you have to do everything yourself. There is not a default HTTP server, or any server for that matter. This can be overwhelming for new users, but the payoff is a high performing web app. One script handles all communication with the clients. This considerably reduces the number of resources used by the application.


Installation

if you use Windows or OS X; the nodejs.org website offers installers for those operating systems, go to http://nodejs.org/ and  you can directly install.



Installing on Windows

Probably asks for cygwin packages, if not installed.

The http://nodejs.org/dist/latest/ directory contains the latest .msi package (such as node-v0.6.15.msi when Node v0.6.15 was the latest) that you may use to install both Node.js engine and npm.

Installing on Mac

The http://nodejs.org/dist/latest/ directory contains the latest .pkg package (such as node-v0.6.15.pkg when Node v0.6.15 was the latest).



Building on GNU/Linux and other UNIX

There's a number of ways to install Node.js on Linux
The filenames vary with the Node's version. The following examples are for Node v0.6.18.



Prerequisites:-

1. GNU make 3.81 or newer. Pre-installed on most systems. Sometimes called gmake.

2. python 2.6 or 2.7. The build tools distributed with Node run on python.

3. libssl-dev (Node v0.6.x only.) Can usually be installed on *NIX systems with your favorite package manager. Pre-installed on OS X.

4. libexecinfo (FreeBSD and OpenBSD only.) Required by V8. pkg_add -r libexecinfo installs it.


Do something like this

tar -zxf node-v0.6.18.tar.gz   #Download this from nodejs.org
cd node-v0.6.18
./configure
make
sudo make install


Or, if you'd like to install from the repository 

git clone https://github.com/joyent/node.git
cd node
git checkout v0.6.18     #Try checking nodejs.org for what the stable version is
./configure
make
sudo make install

You may wish to install Node in a custom folder instead of a global directory. 

./configure --prefix=/opt/node
make
sudo make install