1. Get a repository or package of node.js using following command
sudo apt-get install nodejs
2. After that we need a NodeJS package manager (npm)
sudo apt-get install npm
Run the node.js using the command
node node.js
node.js supports different modules
Examples : socket.io ,express,http..etc
var socket = require( ‘socket.io’ );
var express = require( ‘express’ );
var http = require( ‘http’ );
Install the above modules following the tutorials given below
Cannot find module ‘socket.io’
sudo npm config set registry http://registry.npmjs.org/
sudo npm install -g socket.io
Cannot find module ‘express’
sudo npm install express
Sometime they ask to get new version of node.js
Steps to get the newest version of node.js:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs -y # newer nodejs package includes npm
And then try again to install Express module
sudo npm install express
You almost finished the installation of node.js, Run and use it.
Enter into the particular folder where node js placed.
smarttips@smart-System-Product-Name: cd /var/www/nodechat/
smarttips@smart-System-Product-Name:/var/www/nodechat $ node node.js
Then you will get a message you are connected.
Enjoy Happy coding!!!!!!!