Installation
-Install Xcode.
-Install git.
-Run the following commands:
git clone git://github.com/ry/node.git cd node make sudo make install
Debian (Ubuntu/ Mint)
With Aptitude package manager one can install the package nodeJS then edit their bash config to redirect the command node
to node js
.
sudo apt-get update sudo apt sudo apt
nano (edit / vim) the file ~/.bashrc and add the line: alias node="nodejs"
Redhat (Fedora / CentOs)
Simply install from official repos:
sudo yum install nodejs npm
If that fails, enable EPEL repo:
curl --silent --location https://rpm.nodesource.com/setup | bash -
Then simply install from repo:
yum -y install nodejs
Gentoo
In portage tree:
emerge nodejs
Archlinux
In official repo use pacman package manager:
pacman -S nodejs npm
Linux from source
-Install the dependencies ( Below example using debian apptitude package manager): g++ curl libssl-dev apache2-utils git-core build-essential
sudo apt-get install g++ curl libssl-dev apache2-utils git-core build-essential
-Run the following commands:
git clone git://github.com/ry/node.gitcd node
./configuremake
sudo make install
Interested in mastering Node.js Training? Enroll now for FREE demo on Node.js Training.
Windows
Currently, you must use cygwin to install node. To do so, follow these steps:
-Install cygwin.
-Use setup.exe
in the cygwin folder to install the following packages:
-devel → openssl
-devel → g++-gcc
-devel → make
-python → python
-devel → git
-Open the cygwin command line with Start > Cygwin > Cygwin Bash Shell
.
-Run the below commands to download and build node.
git clone git://github.com/ry/node.gitcd node
./configuremake
sudo make install
Hello Node.js!
Here's a quick program to make sure everything is up and running correctly:
var http = require('http');http
.createServer(function (req, res) { res
.writeHead(200, {'Content-Type': 'text/plain'}); res
.end('Hello Node.js\n');}).listen(8124, "127.0.0.1");console
.log('Server running at http://127.0.0.1:8124/');
Run the code with the node
command line utility:
> node hello_node.jsServer running at http://127.0.0.1:8124/
Now, if you navigate to http://127.0.0.1:8124/ in your browser, you should see a nice message.
For indepth understanding click on