Search code examples
nginxamazon-ec2meteormeteor-up

Meteor Up (mup) on EC2 Deployment Different from Local App


On localhost, the app works just fine.

On EC2, the app runs behind nginx. It loads into the browser, but nothing shows up. The browser console displays an Error

TypeError: 'undefined' is not an object (evaluating 'Package["service-configuration"].ServiceConfiguration')

I have no idea how to tackle this problem. Any help appreciated.

EDIT

  1. NGINX is not the problem. The same behavior if I access meteor server directly.
  2. Running "meteor add service-configuration" does fix the above mentioned error, but the absence of the error does not fix the observed behavior, that the app does not render on EC2 whereas it does render when started on localhost. (The error message was the only visible difference between EC2 and localhost. So I suspected that would be the cause. Now that hypothesis must be wrong.) So the problem still persists.

Problem Solved. The Lesson:

Meteor has a debug mode and a production mode. The two may behave differently. On localhost, meteor runs in debug mode per default. On deploy to meteor.com or per mup, the default is production mode. To run meteor in production mode on localhost, run meteor --production.


Solution

  • It looks like you're trying to access the service-configuration configs on your browser.

    These are not available client side. This also affects your localhost app but it doesn't break your app (doesn't give you a blank page) because meteor is in debug mode.

    In debug mode Meteor files are not concatenated so an error like this would go unnoticed, even if it is thrown on your js console. In production mode the error would halt the rest of your script (since everything is concatenated into a single file)

    You need to ensure the code that is doing this only runs on the server side. In general it's not a good idea to have access to the service configuration data on the client side.