The online home of John Pollard

Developing for Heroku and Node.js on Windows

So I’ve been playing about with some hopefully interesting ideas I’ve been having for a new app - more soon when we have a bit more traction - and have been hacking about using Node.js and MongoDB on Heroku.

It’s been great fun learning some new things, but as ever things have been slightly harder because I’m developing on Windows rather than on a Mac or Linux laptop. Anyway, I thought I’d capture a few things I had to figure out along the way (mainly via Stack Overflow) here, both so I don’t forget them and in case they come in useful to someone else.

Installing MongoDB drivers for node.js

This stumped me for a while. In theory, it should be as simple as running:

npm install mongodb

However, the module has a dependency on the bson module, which will compile itself on install. In theory this shouldn’t be a problem, but out of the box npm is looking for the Visual Studio 2010 C++ compiler, and I only have Visual Studio 2012 installed - and definitely don’t want to install an earlier version as well.

After much searching, I found that there is an option to use VS2012 by using the command:

npm install mongodb --msvs_version=2012

… and everything installed and worked like a dream.

Running Heroku’s Foreman on Windows

I’ve been pretty impressed with the Heroku stack so far. It’s really easy both to deploy your changes by a Git push, and the command-line tools you get make it easy both to configure and monitor what’s going on.

One of the tools was slightly problematic, as Foreman - basically an easy way of running your apps locally - didn’t actually work properly.

Thankfully this was a known issue in version 0.62.0, and the solution was to use 0.61.0 instead which can be installed using:

gem install foreman -v 0.61

… making sure you’ve uninstalled it fully first (using the uninstall command)