Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Tutorial: Meteor on Windows using Vagrant

Requirements

Before doing anything else, install those:

Steps on Windows command-line:

Open cmd: Start > type cmd > ENTER

  1. cd C:\path\to\your\vagrant+meteor\project\folder
  2. mkdir shared
  3. set PATH=%PATH%;C:\Program Files (x86)\Git\bin (Append git binaries to path so vagrant can run ssh - you should add git to your PATH environmental variable permanently so you don't have to run this everytime)
  4. vagrant init ubuntu/trusty32 (Ubuntu 14.04 32bit - use ubuntu/trusty64 for x64)
  5. Edit the Vagrantfile and add the following inside the Vagrant.configure(...) block:
    config.vm.synced_folder './shared', '/home/vagrant/shared'
    
    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
    
  6. Create a new file named mtimv inside the new "shared" folder created on step #2. The contents of the file can be found in below or using the following link: https://gist.github.com/gabrieljenik/d926cbb90706d95abdee#file-mtimv
  7. vagrant up
  8. vagrant ssh

Now that you are inside the VM command-line:

Steps on Ubuntu command-line:

  1. sudo apt-get install curl git
  2. curl https://install.meteor.com | sh
  3. chmod +x ~/shared/mtimv

Creating an app

The idea is to move the .meteor folder out of the shared directory and link it back in. MongoDB cannot run in the shared folder because of permission problems. Create all apps in the ~/shared folder to make their code available to the Windows host. This also applies when you clone an app from git.

Below 2 recipes are given to perform the steps described below.

Recipe #1 - Automatically treating .meteor directory

  1. (cd ~/shared)
  2. Create an app. Example: meteor create --example leaderboard
  3. Run mtimv: ./mtimv leaderboard The app will be automatically launched.

Next time you want to launch it, just follow these steps:

  1. (cd ~/shared/leaderboard)
  2. Run ./mt.sh

Recipe #2 - Creating an app and mounting the .meteor folder manually

This also applies when you clone an app from git. The idea is to move the .meteor folder out of the shared directory and link it back in. MongoDB cannot run in the shared folder because of permission problems. Create all apps in the ~/shared folder to make their code available to the Windows host.

To create the app:

  1. (cd ~/shared)
  2. meteor create --example leaderboard

To move and mount .meteor directory: 3. cd leaderboard 4. mkdir -p ~/mock/leaderboard 5. mv .meteor ~/mock/leaderboard 6. mkdir .meteor

To launch the app 7. cd leaderboard 8. sudo mount --bind /home/vagrant/mock/leaderboard/.meteor .meteor 9. meteor (finally!) 10. Go to http://localhost:3000 in Windows browser!

Hints:

  • Make sure you do version control INSIDE THE VM, so the software can follow the mounted .meteor directory.
  • You will have to remount (step 7 above) the .meteor directory on every vagrant restart. Mount the directory before you do any version control!
  • To halt a vagrant VM: vagrant halt
  • To destroy a VM: vagrant destroy
  • You might want to run sudo apt-get update in the VM to install the latest Ubuntu security updates

Original tutorial by @gabrielsapo

#!/bin/sh
# ------------------------------------------------------------------
# [Gabriel Jenik] Meteor internal move
#
# Meteor-Vagrant-Win Environment.
# After meteor create app script to move .meteor dir to VM FS.
#
# The idea is to move the .meteor folder out of the shared directory and link it back in.
# MongoDB cannot run in the shared folder because of permission problems.
# Create all apps in the ~/shared folder to make their code available to the Windows host.
#
# Install: 1) Put it in the ~/shared dir.
# 2) run: chmod +x mtimv
# ------------------------------------------------------------------
VERSION=0.1.0
SUBJECT=gj_meteor_after_create
USAGE="Usage: mtimv app_name"
# Move meteor internal directory
cd $1
mkdir -p ~/mock/$1
mv .meteor ~/mock/$1
mkdir .meteor
# Add mount to the all-apps mount shell script.
echo "#-------------" >> ~/shared/mtimnt.sh
echo "#$1 internal meteor directory mount" >> ~/shared/mtimnt.sh
echo "sudo mount --bind /home/vagrant/mock/$1/.meteor ~/shared/$1/.meteor" >> ~/shared/mtimnt.sh
# Create a meteor-start shell script that performs individual mount and runs meteor.
echo "#-------------" > ~/shared/$1/mt.sh
echo "#$1 applictaion meteor start replacement" >> ~/shared/$1/mt.sh
echo "sudo mount --bind /home/vagrant/mock/$1/.meteor .meteor" >> ~/shared/$1/mt.sh
echo "meteor" >> ~/shared/$1/mt.sh
chmod +x ~/shared/$1/mt.sh
# Start App
cd ~/shared/$1
./mt.sh
@ppkn

This comment has been minimized.

Copy link

@ppkn ppkn commented Jan 19, 2015

Thanks for this! It helped. At first I couldn't get mtimv to work:

vagrant@vagrant-ubuntu-trusty-64:~/shared$ ./mtimv leaderboard
./mtimv: line 18: $'\r': command not found
: No such file or directoryrboard
mv: cannot stat ‘.meteor’: No such file or directory
mkdir: cannot create directory ‘.meteor\r’: Protocol error
./mtimv: line 24: $'\r': command not found

Turns out that Windows inserted carriage returns when I copy/pasted the file. Instead I just ran wget https://gist.githubusercontent.com/gabrieljenik/d926cbb90706d95abdee/raw/85a03ac12e013656bf7e01b2ba95a8a4fd1c1475/mtimv from my ~/shared directory. It works great.

@athergeek

This comment has been minimized.

Copy link

@athergeek athergeek commented Feb 3, 2015

Hi i was able to successfuly setup everything till i had to shutdown my VM and restart. Now whenever i try to create a new application using "meteor create testapp" i am getting following error

vagrant@vagrant-ubuntu-trusty-32:~$ cd /shared
vagrant@vagrant-ubuntu-trusty-32:
/shared$ meteor create testapp

/home/vagrant/.meteor/packages/meteor-tool/.1.0.40.1alfjqv++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/fibers/future.js:206
throw(ex);
^
Error: EACCES, mkdir '/home/vagrant/shared/testapp'
at Object.Future.wait (/home/vagrant/.meteor/packages/meteor-tool/.1.0.40.1alfjqv++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/fibers/fu
at Object.wrapper as mkdir
at Object.files.mkdir_p (/home/vagrant/.meteor/packages/meteor-tool/.1.0.40.1alfjqv++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/tools/files.js:397:11)
at Object.files.cp_r (/home/vagrant/.meteor/packages/meteor-tool/.1.0.40.1alfjqv++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/tools/files.js:429:9)
at Command.buildCommands.minArgs [as func] (/home/vagrant/.meteor/packages/meteor-tool/.1.0.40.1alfjqv++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/tools/commands.j
at /home/vagrant/.meteor/packages/meteor-tool/.1.0.40.1alfjqv++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/tools/main.js:1300:23
- - - - -
vagrant@vagrant-ubuntu-trusty-32:~/shared$

@athergeek

This comment has been minimized.

Copy link

@athergeek athergeek commented Feb 3, 2015

ok it turned out may be it was because of improper shut down. I tried following and it worked.

  1. type : exit to get out of linux command prompt
  2. type : vagrant halt to halt vm
    3 )type : vagrant up to get back up and running
  3. type : cd ~/shared
  4. type : meteor create testapp ( app got created successfully )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment