Setting up Meteor.js on Nitrous.IO
/Nitrous.IO (referral link - non-referral link) is a in-browser development environment built atop Amazon's AWS.
It gives you a linux shell in the browser, as well as a text editor and collaboration features.
I wanted to learn more about the service, so I decided to create an account and set up Meteor.js. Since i'm not a linux guru, it took me a bit of time. I'm writing this post for two reasons. One: to document what I did in case I want to reference it in the future, and two: the off chance my experience with the process can help someone else.
Note: I used MongoHQ as my database service.
Part 1
Getting the various SaaS accounts and database in order. Each of the below services make it easy to create accounts, so I won't go into detail.
1) Create Nitrous.IO account
2) Provision a Node.js box in Nitrous.IO
3) Create an account and database in MongoHQ (make note of the host, port, database username, database password after the DB is created)
Part 2
Install Meteor.js (as explained in Meteor's Quick Start guide)
In the Nitrous.IO browser console run the command:
curl https://install.meteor.com | /bin/sh
After installation, Meteor will attempt "Writing a launcher script to /usr/local/bin/meteor for your convenience." but can't do it since you don't have sudo access in Nitrous.IO
No worries. Click "Show Hidden" to reveal the hidden files in your Nitrous box. One of these hidden files is your .bash_profile.
Now you can add these lines of code to your .bash_profile:
#add meteor to PATH
PATH=$PATH:~/.meteor
export PATH
Part 3
Configure environmental variables and connect Node.js to your MongoHQ database
After creating a database in MongoHQ, you'll get the info you need to fill in the below environmental variables.
Put this in your .bash_profile so it'll become part of your environment on startup.
#DB info
export MONGOHQ_DEV_HOST=your.mongohq.host
export MONGOHQ_DEV_PORT=your-host-port
export MONGOHQ_DEV_DB=your-database-name
export MONGOHQ_DEV_USERNAME=your-database-username
export MONGOHQ_DEV_PASSWORD=your-database-password
export MONGOHQ_DEV_URI=mongodb://$MONGOHQ_DEV_USERNAME:$MONGOHQ_DEV_PASSWORD@$MONGOHQ_DEV_HOST:$MONGOHQ_DEV_PORT/$MONGOHQ_DEV_DB
After you have your environmental variables set up, you can tell Node.js what DB to use with MONGO_URL
Example:
export MONGO_URL=mongodb://$MONGOHQ_DEV_USERNAME:$MONGOHQ_DEV_PASSWORD@$MONGOHQ_DEV_HOST:$MONGOHQ_DEV_PORT/$MONGOHQ_DEV_DB
Download an example bash_profile in plain text
To add these changes to the environment immediately (instead of restarting) run:
source ~/.bash_profile