I am using ember-cli and have a problem with selecting the production environment. Specifically, everything works when I run ember serve --environment=development
and I get a blank page when I run ember serve --environment=production
. In the console, I see:
- Uncaught TypeError: undefined is not a function
- Uncaught Error: Could not find module simple-auth/authenticators/base
All other things are equal, and all dependencies are up to date. I'm a total noob so I don't even know where to begin on how to debug: is it ember? ember-cli? broccoli? Any help would be appreciated.
I had exact the same problem, and James_1x0 is correct, it is an broccoli issue. After debugging it occurs, that the "undefined" error apears on "Ember.handlebars.compile" which lead to other research. It seems, that in production envrironment "handlebars.js" is replaced by "handlebars.runtime.js" in the ember-cli build process, which seem to be a problem for broccoli at this time.
Other devs had the same problem but with other libraries as well: https://github.com/stefanpenner/ember-cli/pull/675#issuecomment-47431195
Here the solution was to add:
into your Brocfile.js to replace the "handlebars.runtime.js" with the "handlebars.js". This also fixed the problem for me. It sure has the drawback that the whole handlebars file is deployed but its a workarround for now, until the problem is fixed.
Solution is mentioned on Ember CLI website:
Basically, you can pass
vendorFiles
option to yourEmberApp
instance which will force CLI to include full version of Handlebars.Example of explicitly requiring
handlebars.js
, inBrocfile.js
:This is recommended way of solving this issue(discussion on GitHub).