Posted on February 1, 2017 by admin

Install Nodejs on Ubuntu 14.04

 How To Install the Distro-Stable Version

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. The version in the repositories is 0.10.25. This will not be the latest version, but it should be quite stable.

In order to get this version, we just have to use the apt package manager. We should refresh our local package index prior and then install from the repositories:

sudo apt-get update
sudo apt-get install nodejs

If the package in the repositories suits your needs, this is all that you need to do to get set up with Node.js. In most cases, you’ll also want to also install npm, which is the Node.js package manager. You can do this by typing:

sudo apt-get install npm

This will allow you to easily install modules and packages to use with Node.js.

Because of a conflict with another package, the executable from the Ubuntu repositories is called nodejsinstead of node. Keep this in mind as you are running software.

Below, we’ll discuss some more flexible methods of installation.

If you are using this kind of installation the NodeJS binary would be “nodejs”.

It could be a good practice to link it with the more common name;

sudo ln -s /usr/bin/nodejs /usr/bin/node

How To Install Using a PPA

An alternative that can get you a more recent version of Node.js is to add a PPA (personal package archive) maintained by NodeSource. This will probably have more up-to-date versions of Node.js than the official Ubuntu repositories.

First, you need to install the PPA in order to get access to its contents. This depends on the version you wish to install.

For the most recent LTS (the 6.x branch), use:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

For the older LTS (the 4.x branch), use:

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -

For the currently active release (the 7.x branch), use:

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -

The PPA will be added to your configuration and your local package cache will be updated automatically. After running the setup script from nodesource, you can install the Node.js package in the same way that you did above:

sudo apt-get install nodejs

The nodejs package contains the nodejs binary as well as npm, so you don’t need to install npmseparately. However, in order for some npm packages to work (such as those that require building from source), you will need to install the build-essentials package:

sudo apt-get install build-essential