Installing Node.js on Ubuntu 12.04 LTS

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. This tutorial will help you install Node.js on your Ubuntu 12.04 LTS.

First, ssh into your Pod as root. In this example, the Pod’s hostname is nodepod. Once logged in, Node.js can easily be installed with the apt-get package manager:

root@nodepod:~# sudo apt-get update
root@nodepod:~# sudo apt-get install python-software-properties python g++ make
root@nodepod:~# sudo add-apt-repository ppa:chris-lea/node.js
root@nodepod:~# sudo apt-get update
root@nodepod:~# sudo apt-get install nodejs 

That’s it. You can now test that the install worked correctly by writing your first Node.js program, and running it.

Create a file called hello.js, containing the below:

console.log("Hello, world.");

You can run this as bellow, and should see “Hello, world” as the output.

root@nodepod:~# node hello.js

Enjoy! And by the way, we love Node.js. We recommend looking into npm to install different packages, and the excellent Express framework, next.

Matthew McCaffrey

Leave a Reply