How to install Node.js in Ubuntu 14.04

In order to install the Node.js in Ubuntu 14.04 we just need to run the following commands:
sudo apt-get update
sudo apt-get install nodejs
It will not install the latest version of Node.js but it will be very stable to work with. If we want to check the Node.js installation, we can type following command and see the version:

node -v 
If the above command does not work, then we can try the following command:
nodejs -v
If node of the commands do not show the Node.js version, then the Node.js installation is not correct. We will have to try the Node.js installation again. Now if we have a situation where nodejs -v works but node -v does not work, then we need to run the following command to make that work.
sudo ln -s `which nodejs` /usr/bin/node
In many other cases it will be necessary to install node project manager (NPM). The npm is called Node.js package manager. We can install NPM by typing following command:
sudo apt-get install npm
Once we have npm installed we can easily install express framework using following command:
 
sudo npm install -g express-generator
To check whether express framework is installed or not, we can run the following command:
express -V
Now we can create an application using express framework using following command:
sudo express myapp
Once the application is created we can start installing dependencies using following commands:
cd myapp 
npm install

Comments