In this tutorial, we will show you how to install Node.js on your Ubuntu 14.04 server. For those of you who didn’t know, Node.js is a Javascript platform for programming that enables users to build network applications very quickly. If you are using Javascript on both the front end and the back end, it means your development can be much more consistent and be designed within the same system.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you the step-by-step installation of Node.js on the Ubuntu 14.04 server.
Prerequisites
- A server running one of the following operating systems: Ubuntu 14.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Node.js.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Node.js on Ubuntu 14.04
Step 1. First of all, make sure that all packages are up to date.
apt-get update apt-get upgrade
Step 2. Install Node.js using the repository.
Install the node.js package, the command is:
sudo apt-get install nodejs
Install NPM (Node Package Manager) as well for package management, the command is:
sudo apt-get install npm
Verify the current version of Node.js installed:
node -v
Step 3. Install Node.js using the PPA repository for Ubuntu 14.04.
First, add node.js PPA in our system using the following set of commands:
sudo apt-get install python-software-properties sudo apt-add-repository ppa:chris-lea/node.js sudo apt-get update
Install the node.js package, the command is:
sudo apt-get install nodejs
Install NPM (Node Package Manager)to manage your package:
sudo apt-get install npm
Verify your version of Node.js installed:
node -v
Step 4. Install Node.js using NVM (Node.js Version Manager).
Using nvm, you will be able to install multiple, self-contained versions of Node.js which will mean you can control your environment much easier. It will give you on-demand access to the latest versions of Node.js, but it will also allow you to specify previous releases that your app may need. 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
Download then install the nvm script with the following command or get them from the GitHub page:
curl https://raw.githubusercontent.com/creationix/nvm/v0.7.0/install.sh | sh
The software will install in a subdirectory of your home directory ~/.nvm
and will add the necessary lines to your ~/.profile
file to use the file. With the following command, source the ~/.profile in order for your session to know about these changes and you can access the nvm functionality:
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
[root@idroot.us ~]# nvm ls-remote . . . v0.11.6 v0.11.7 v0.11.8 v0.11.9 v0.11.10 v0.11.11 v0.11.12 v0.11.13
Install the version you want with the command:
nvm install [your version]
Example:
nvm install 0.11.13
Configure nvm to use the version of Node.js that you just downloaded, the command is:
nvm use 0.11.13
To verify the current version of Node.js installed, the command is:
node -v
Congratulations! You have successfully installed Node.js. Thanks for using this tutorial for installing Node.js in Ubuntu 14.04 system. For additional help or useful information, we recommend you check the official Node.js website.