Meteor client app fails with Package.modules undefined using --production


I am upgrading Meteor from version 1.5.1 to Had faced few issues while upgrading as below:

  • ssrwpo:uglifyjs2 babel constraint. This was fixed by locally overriding the package & updating the babel constraint to 7.0.7. Referred this.
  • Babel compiler issue was fixed by following babel upgrade steps as mentioned here.
  • WebAppInternals.getBoilerplate was returning stream instead of string as before. So html-minifier stopped working as it expected string. So fixed it by converting stream to string & promise as it became async.

After this the app was working properly locally using the command:

meteor --settings settings-default.json

But when deployed my code to Heroku, the client side app fails with errors specifying that lot of modules like meteor-base, babel-runtime, ecmascript-runtime etc were not loaded. Browser console shows this error (an example of babel-runtime error):

Uncaught TypeError: Cannot read property 'meteorInstall' of undefined
    at babel-runtime.js?hash=ad2513735fa8d9d75196ab30ea0bd927586919be:17
    at babel-runtime.js?hash=ad2513735fa8d9d75196ab30ea0bd927586919be:149
(anonymous) @ babel-runtime.js?hash=ad2513735fa8d9d75196ab30ea0bd927586919be:17
(anonymous) @ babel-runtime.js?hash=ad2513735fa8d9d75196ab30ea0bd927586919be:149

When I checked line 17 of babel-runtime it shows below code of which modules is undefined which is why it fails:

var meteorInstall = Package.modules.meteorInstall;

On Heroku, we are using meteor-buildpack-horse to build our app. When I checked the commands that it uses I saw its using --production flag while running as shown here.

So I tried the same on local using command & got the same issues on local:

meteor --settings settings-default.json --production

Can someone please help or point out what could be happening here with --production flag?


The --production flag just consolidates and minifies. It’s still a dev environment:

Thank you @robfallows. I read this & seems this should not cause the issue I am facing as its just minifying whatever data we give it to.

The next thought I have is npm install command that build pack is using also has --production flag that is related to npm install command which installs all dependencies & no devDependencies.

Could this be somehow related?

Perhaps: if you have some dependencies defined in your package.json as dev, when they should be prod.

Ok I got a fix, but the behavior I observed was little strange.

We are using ssrwpo:ssr package & in that it uses html-minifier to minify the HTML.

It is using 3 options for minification code is here:

  • removeScriptTypeAttributes - Remove type=“text/javascript” from script tags. Other type attribute values are left intact.
  • removeStyleLinkTypeAttributes - Remove type=“text/css” from style and link tags. Other type attribute values are left intact.
  • collapseWhitespace - Collapse white space that contributes to text nodes in a document tree.

When I disable removeScriptTypeAttributes the site works perfectly with no errors.

I was wondering how type="text/javascript" could result into these errors?