DEV Community

Mohan Upadhyay for The Coders Blog

Posted on • Originally published at thecodersblog.com on

How to run meteor in windows and Ubuntu using vagrant?

Here are the steps for running meteor in windows and Ubuntu using vagrant.

Pre-requirements

  • Download VirtualBox [Vagrant runs on top of VirtualBox, so you need it]
  • Download latest Vagrant
  • Download git [It will install ssh binaries required by Vagrant and let you connect to the VM]
  • Create a folder to store your Vagrant files + Meteor project
  • Copy script below and save it as meteor.sh into that folder.
#!/bin/bash
sudo apt-get update
sudo apt-get install python-software-properties
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | sudo tee -a /etc/apt/sources.list.d/10gen.list
sudo apt-get update
sudo apt-get install -y git mongodb-10gen curl
cd /usr/local
wget http://nodejs.org/dist/v0.8.23/node-v0.8.23-linux-x86.tar.gz
sudo tar -xvzf node-v0.8.23-linux-x86.tar.gz --strip=1
rm -f node-v0.8.23-linux-x86.tar.gz
curl https://install.meteor.com | sudo sh
sudo npm install -g meteorite
Enter fullscreen mode Exit fullscreen mode

Steps on Windows command-line:

  1. Go to Start Menu > Type cmd > SHIFT + ENTER (to login as Administrator)
  2. cd C:\path\to\your\vagrant+meteor\project\folder
  3. set PATH=%PATH%;C:\Program Files (x86)\Git\bin (Append git binaries to path so vagrant can run ssh)
  4. vagrant init precise32 http://files.vagrantup.com/precise32.box (To install Ubuntu 10.04 x86)
  5. Edit the Vagrantfile with your preferred editor and add those four lines anywhere inside the Vagrant.configure(“2”) block:
config.vm.provision :shell, :path => "meteor.sh"
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.provider "virtualbox" do |v|
    v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
Enter fullscreen mode Exit fullscreen mode
  1. vagrant up (It will download box, configure meteor and get it up)
  2. vagrant ssh (It will connect on the VM and expose its command-line)

Now that you are inside the VM command-line, you can use it as your server:

Steps on Ubuntu command-line:

  1. cd /vagrant
  2. mrt create ~/meteorapp
  3. mrt create meteorapp && cd meteorapp && rm -rf .meteor && mkdir .meteor/ (Check your Windows folder you’ve created. It will be there!)
  4. Input these lines:
sudo mount --bind /home/vagrant/meteorapp/.meteor/ /vagrant/meteorapp/.meteor/
echo “sudo mount --bind /home/vagrant/meteorapp/.meteor/ /vagrant/meteorapp/.meteor/” >> ~/.bashrc && source ~/.bashrc
mrt run
Enter fullscreen mode Exit fullscreen mode

It should be running on http://localhost:3000.

The point here is to use the .meteor folder of your app pointing to another place inside the VM (run ls -la .meteor/ on command-line and you will see the symbolic link), so Meteor uses the VM folder, not Windows folder, and won’t have permissions problems. You will also need to do all git flow inside Ubuntu command-line, because Windows can’t follow those links.

Hints

  • Make sure you do version control INSIDE THE VM, so the software can follow the symlink.
  • To halt a vagrant VM: vagrant halt
  • To restart a vagrant VM without running all Meteor installation again: vagrant reload --no-provision or just remove the shell path you’ve put on Vagrantfile on line 10.
  • To destroy a VM: vagrant destroy

Reference

Meteor in Windows using Vagrant gist by @gabrielhpugliese.

Top comments (0)