It’s easy to install node.js on a Raspberry Pi and makes for a great lightweight webserver to serve as an interface for web projects.

Before installing node you’ll need to install build-essential (and git-core if you are going to use git for version control).

sudo aptitude install build-essential git-core

I went with v0.11.0 of node, but you can check out the versions available here. Building from source took a couple of hours, but the install step was relatively quick.

tar xzf node-v0.11.0.tar.gz
cd node-v0.11.0.tar.gz
sudo make install

When node is finally installed, you can create a simple app to check everything is working correctly.

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('It works!\n');
}).listen(8124, "");
console.log('Server running at');

Firing up your browser and hitting should give you a page with the message “It works!” Or you can quickly verify with curl:

% curl
It works!