Installing node.js on Vagrant

I wanted to share this Vagrant bootstrap file which installs the latest version of node on Vagrant – it took me a while to figure this out when I was getting started with Vagrant, which is probably just a reflection of my elementary unix skills. Anyway, here’s the bootstrap file:

sudo apt-get update
sudo apt-get install python-software-properties -y
sudo add-apt-repository ppa:chris-lea/node.js -y
sudo apt-get update -y
sudo apt-get install nodejs -y
sudo apt-get install build-essential g++

And because this is aimed at beginners here’s the Vagrant file for reference too!

Vagrant.configure("2") do |config| = "precise32"
  config.vm.provision :shell, :path => '' :forwarded_port, guest: 80, host: 8080

Simply pop these 2 files in a new directory, name them and Vagrantfile respectively, and then exec the vagrant up command in your terminal and you will have a new node.js development environment to play with – excellent!