How to pass command line arguments to a Meteor app?

meteor

Solution

Meteor doesn't forward command line args to your app, if it doesn't know them. You have multiple possibilities:

- Rewrite parts of `meteor.js` to forward unrecognized args. This shouldn't be too hard, but it's not a pretty solution. And if updates occur you are in trouble. :D

- You could write a small config file and change the behaviour of your app based on the configuration options in there. Take a look at this question.

- The easiest thing to do is using environment variables. You can read env vars in node like this. After that you can start your app the "express.js" way: `$ METEOR_ENV=production meteor`

I hope I could help you! :)

Problem

I would like to pass command line arguments to my Meteor app on start up. For example --dev, --test or --prod indicating whether or not it is running in dev, test or prod environments. It can then load different resources on start up, etc... I tried something like this in a /server/server.js ``` var arguments = process.argv.splice(2); console.log('cmd args: ' + JSON.stringify(arguments,0,4)); ``` The I ran a test. And quite a few others with just random command line arguments. ``` meteor --dev ``` The output in the console is only this. ``` cmd args: [ "--keepalive" ] ``` What is the best way to get command line arguments into a Meteor app? Or, is this even the correct way to solve the higher level problem? and if not, what is the correct way to solve this problem of distinguishing between running enviro?

Original source

Related problems