Matt The Ninja Matt The Ninja - 2 months ago 8x
Node.js Question

Running Meteor Build under Node with settings argument

Typically when developing I would use

meteor run --settings settings.json
. This works fine and can view the settings in the browser with
on the console.

I am now build for production, using
meteor build
, I've looked at the documentation and there is nowhere to add
during the build process.

So the build runs and I have my
file, it's loaded to production and then I untar/compress the folder and run the start script.

It enters the program with
npm start
and the package.json section looks like this (ignore the stop script);

"name": "myapp",
"scripts": {
"start": "node main.js --settings settings.json",
"stop": "killall node"

When I look at my app it is not collecting these settings. It is as if when bundled it doesn't expect the arguements. I also tried using forever beforehand, but I had no joy with this either.

Any help would appreciated, start to wish I never bothered with Meteor :)


You can refer to Meteor Guide > Production > Deployment and Monitoring > Environment variables and Settings

Settings. These are in a JSON object set via either the --settings Meteor command-line flag or stringified into the METEOR_SETTINGS environment variable.

As for setting environment variables, if you use a 3rd party host, you may have a GUI or CLI to define them.

Otherwise, you should have plenty resources including on SO:

In short, it should look like:

METEOR_SETTINGS='{"key":"value"}' node main.js

You can also try the bash cat command to extract the content of a file: $(cat settings.json)