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.
Solution is mentioned on Ember CLI website:
This is somewhat non-standard and discouraged, but suppose that due to a requirement in your application that you need to use the full version of Handlebars even in the production environment.
Basically, you can pass vendorFiles
option to your EmberApp
instance which will force CLI to include full version of Handlebars.
Example of explicitly requiring handlebars.js
, in Brocfile.js
:
var app = new EmberApp({
vendorFiles: {
'handlebars.js': {
production: 'bower_components/handlebars/handlebars.js'
}
}
});
This is recommended way of solving this issue(discussion on GitHub).
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:
var index = app.legacyFilesToAppend.indexOf('bower_components/handlebars/handlebars.runtime.js');
if(index) {
app.legacyFilesToAppend[index] = 'bower_components/handlebars/handlebars.js';
}
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.
来源:https://stackoverflow.com/questions/25018160/ember-cli-fails-on-environment-production-uncaught-error-could-not-find-modu