Modulus

Run Meteor Apps Anywhere with Demeteorizer

Run Meteor Apps Anywhere with Demeteorizer

Meteor is an ambitious project that aims to reduce the amount of time it takes to write and deploy high-quality apps. I would compare it to Rails if I weren’t afraid of the response I would get to saying something like that, so let’s just call it a set of tools and a JavaScript framework.

At its core, Meteor apps sit on top of Node.js, which means we should technically be able to run a Meteor app anywhere Node will run. This is mostly true by using Meteor’s built-in “bundle” command, however it doesn’t produce something that’s extremely portable. This is why we created Demeteorizer.

Demeteorizer wraps and extends Meteor’s bundle command by creating something that more closely resembles a standard looking Node.js application, complete with a package.json file for dependency management.

Installing

$ npm install -g demeteorizer

Usage

demeteorizer [options]
$ cd /my/meteor/app
$ demeteorizer -o ~/my-meteor-apps/converted -n v0.8.24

Options

--output, -o Sets the output folder for the converted applications. Defaults to .demeteorized. Optional.
--node_version, -n Sets the value of Meteor’s hard-coded MIN_NODE_VERSION variable. Defaults to v0.8.24. Optional.

Example

Let’s look at what happens when we run Demeteorizer on Meteor’s leaderboard example:

$ meteor create --example leaderboard

Now let’s run Demeteorizer on this Meteor project.

$ demeteorizer

The result is very similar to what you get when you run “meteor bundle”, however a package.json file is automatically generated with all required dependencies. It also overrides a line of code in server/server.js that is a hard-coded check for the Node.js version.

Now we can run this Meteor application just like any other Node.js application. Meteor does require some environment variables that must be set.

MONGO_URL='mongodb://user:password@host:port/databasename?autoReconnect=true&connectTimeout=60000' ROOT_URL='http://example.com' (optional) PORT=8080 (optional, defaults to 80) MAIL_URL='smtp://user:password@mailhost:port/' (optional)

$ cd /my/converted/app
$ npm install
$ export MONGO_URL='mongodb://user:password@host:port/databasename?autoReconnect=true&connectTimeout=60000'
$ export PORT=8080
$ node main.js

You can now go to localhost:8080 and see the leaderboard example.

What is Modulus?

Modulus is a home for web applications. Node.js hosting, integrated MongoDB, and performance metrics all in one place. It’s free to get started.

Share This Article

comments powered by Disqus