This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:
Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.
Feel free to skip this section if you have a compiler and curl installed on your droplet. These steps are included since both a compiler and curl are required for the node.js installation itself. Additionally, you will need to have sudo privileges on your virtual private server for the next three commands (the actual installation does not require them).
Go ahead and run an apt-get update before starting to install any of the requirements.
sudo apt-get update
Once the update finishes, install a compiler on your VPS.
sudo apt-get install build-essential
Additionally, be sure to download curl, which we will need to perform the installation itself.
sudo apt-get install curl
Once those two components have downloaded, you are all ready to install node.js.
I found the method described below to be the easiest way to install node.js. According to their site, there are eight ways to install node.js, and you can check out the other possibilities if you prefer.
This specific installation is very straightforward and installs node.js on the user's local system alone.
Start by changing the path to include commands from the ~/local/bin directory.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
Follow up by sourcing the .bashrc file:
Create two new directories for the installation:
mkdir ~/local mkdir ~/node-latest-install
Switch into the latest-install folder:
Run curl to get the node.js tarball and subsequently untar it.
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
Once that has completed, you can go ahead and start the installation process, limiting it to the local user. This ensures that you will not need sudo later.
Run make install, but be warned: it does take a while.
Finish up by downloading the the node package manager through curl:
curl -L https://npmjs.org/install.sh | sh
After you are all done, you can quickly check which version you have installed on your virtual private server.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.Sign up
Click below to sign up and get $100 of credit to try our products over 60 days!