Installing Node on Linux (v0.12 version)

This is a really quick, short, post. As I was working on the “Creating a Docker Build for your Node application” post, I realized there was a lot of bad information out there about how to install Node on your Ubuntu Linux system. It isn’t in the standard repositories and most of the “high in the list on Google” posts are just plain wrong. There is a canonical source for the information but it wasn’t high on the search results.

I doubt this will make it into the first page of Google either, but hopefully it helps my readers.

To install Node on Linux, do the following:

curl -sL | sudo bash -
sudo apt-get install -y nodejs

The first line installs a new repository on your Ubuntu Linux system specifically for installing Node. If you don’t have curl, it will tell you. You can install it with this command:

sudo apt-get install curl

You will note that the output looks a lot like the output from apt-get update – that’s because once you’ve installed the repository, you need to refresh everything. The second line actually installs everything.

To test the install, run node -v – it should say v0.12.4 (or later, depending on when you are doing this). I also put together a quick copy of my node experiment. You can clone the repository and get it started like this:

git clone
cd node-stuff/docker-app
npm install
cp config-default.json config.json
nano config.json
node server.js

When using nano (or gedit or vi – pick your favorite editor), just replace the Auth0 parameters with your own. Once done, the server should start on port 3000 just like before. You should be able to start Firefox on the Ubuntu server and browser to http://localhost:3000 – you will be prompted to choose the social login. Everything should work just like it did before.

While you are at it, you may want to cut-and-paste between your Windows box and the Ubuntu box. To do that, you want to install two packages – one on the Linux side and one on the Windows side. The Windows side requires PuTTY – an ssh tool (although there are others out there). The other is an ssh server on the Ubuntu box. To install that, do the following in a Terminal window:

sudo apt-get install openssh-server
sudo service ssh restart

The official documentation on this process is on the Ubuntu website. If you run into trouble, make sure Password Authentication is enabled and that the server is listening on port 22. You can do this by editing /etc/ssh/sshd_config and looking for the appropriate options. If you edit this file, restart the service again.

Once you have that running, use ipconfig eth0 to find out the IP address of your Ubuntu server and run PuTTY. The right mouse button is paste in Linux. Now you can easily cut-and-paste between the Auth0 website and the terminal window.

NOW I’m ready to do that Docker build!