This is probably the quickest way to install nodejs and npm on 12.04. For compiling and install from source check this.
Use launchpad repo by Chris Lea
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
Install node.js
sudo apt-get install nodejs
Check node.js and npm versions.
node -v
npm -v
In case there are problems with permissions and access errors.
sudo chown -R $(whoami) ~/.npm
Works on Ubuntu 12.04. But the version is 0.10.37.