3 Options To Install Node.js on Ubuntu 14.04

Posted on : February 10, 2015 , Last Updated on : February 9, 2015 By
| Reply More

Hi everyone, today we'll learn how to install Node.js on an Ubuntu 14.04 LTS "Trusty" Server . So, here below is a short description on what is Node.js and its short history.

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. It is a Javascript platform for server-side programming that allows users to build network applications quickly. By leveraging Javascript on both the front-end and the back-end, development can be more consistent and be designed within the same system.

So, here are the 3 different ways we could install Node.js on an Ubuntu 14.04 Server or PC.

1. Installing NodeJS using Repository

Ubuntu 14.04 contains a version of Node.js in its default repositories that can be used to easily provide a consistent experience across multiple servers. In order to install this version, we just have to use the apt package manager. We should update our local package index and then install from the repositories. To do so, we'll need to run the following commands in a shell or terminal.

$ sudo apt-get update

Updating Repo Index

After we finish updating our local repository index, we'll install nodejs and npm. Where, NPM is a package manager for JavaScript, and is default for Node.js. It also allows users to install Node.js applications that are available on the npm registry. npm runs through the command line and manages dependencies for an application

$ sudo apt-get install nodejs

Installing nodejs

$ sudo apt-get install npm

Installing NPM

We have sucessfully installed nodejs and npm in our Ubuntu 14.04 Server using the default distro's repository. Now, we'll move towards installing it using a PPA.

2. Installing Using a PPA

We can install Node.js using a PPA in Ubuntu Server. PPA can be added by running the following command in a terminal or a shell.

$ curl -sL https://deb.nodesource.com/setup | sudo bash -

The above command will add local repository index and update the sources automatically. After its done, we'll then install nodejs by running the following commands:

$ sudo apt-get install nodejs

$ sudo apt-get install build-essential

3. Installing Using NVM

NVM stands for Node Version Manager which is a neat and clean script that allows us to manage multiple versions of Node.js to use in the same box. So, first we'll want to update our local repository index and then install libssl-dev and build-essential . That can be done by running the below commands in a terminal or shell.

$ sudo apt-get update
$ sudo apt-get install build-essential libssl-dev

installing build essential libssl

After they are done, we'll need to download nvm and install it. We can do that by running the below command:

$ curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh

Installing NVM

It will install the software into a subdirectory of your home directory at ~/.nvm . It will also add the necessary lines to your ~/.profile file to use the file.

To gain access to the nvm functionality, we'll need to log out and log back in again, or we can source the ~/.profile file so that our current session knows about the changes:

$ source ~/.profile

source profile

Now as we have nvm installed, we can install isolated Node.js versions.

To find out the versions of Node.js that are available for installation, we need to type:

$ nvm ls-remote

Available NodeJS versions

As we can see above, the current newest version is v0.11.16 . We can install it by executing the following command:

$ nvm install 0.11.16

Installing NVM nodejs

Usually, nvm will switch to use the most recently installed version. We can explicitly tell nvm to use the version we just downloaded by typing:

$ nvm use 0.11.16

When we install Node.js using nvm, the executable is called node. We can see the version currently being used by the shell by typing:

$ node -v

use NodeJS version

If we have multiple Node.js versions, we can see what is installed by typing:

$ nvm ls

If we wish to default one of the versions, we need to run as:

$ nvm alias default 0.11.16

Managing Multiple NodeJS


Hurray! We have successfully installed Node.js in our Ubuntu 14.04 LTS Server. In this tutorial, we learned how to install Node.js with 3 different ways, those were using the official repository, PPA and NPM. It is a Javascript platform for server-side programming that allows users to build network applications quickly. There is a high demand of Node.js programmers and experts in the global market of IT and Software Industry. If you have any questions, comments, feedback please do write on the comment box below and let us know what stuffs needs to be added or improved. Thank You! Enjoy NodeJS :-)

Filed Under : UBUNTU HOWTO

Free Linux Ebook to Download

Leave a Reply

All comments are subject to moderation.