ajeurissen
ajeurissen

Reputation: 85

Ember-cli require("my_app/app")["default"].create is not a function

I'm migrating my project from a situation where it was a nested asset in a Rails app to a separate frontend with Ember-Cli. And I've been stuck with the following problem for quite some time now:

When running $ Ember serve in my terminal and opening localhost:4200 with Chrome I get the following error in the console: Uncaught TypeError: undefined is not a function in app-boot.js:25

On that line the following code is present:

require("my_app/app")["default"].create({
  "defaultLocale":"en",
  "name":"my_app",
  "version":"0.0.0.bece32c1"
});

I added a breakpoint on that line and checked if require("my_app/app" was defined, and it was Object {default: Class} so I checked if the default object property was defined, and this also was the case:

Class {modulePrefix: "my_app", podModulePrefix: undefined,
       Resolver: function, _readinessDeferrals: 1, $: function…}

The console output of require("my_app/app")["default"] can be seen in the following screenshot:

enter image description here

This is the content of my config/environment file:

enter image description here

And this is the content of my app/index.html file:

enter image description here

And this is the content of my app/app.js file:

enter image description here

I'm using the latest version of Ember-cli, Ember v1.10.0, ember-data v1.0.0-beta.15 and Jquery 1.11.2

============= Update 1: origin of app-boot.js ==================

Someone asked where the app-boot.js was located as he was only familiar with https://github.com/ember-cli/ember-cli/blob/master/lib/broccoli/app-boot.js Below is a screenshot of the resources pane in Chrome, showing that it is in fact a compiled vendor asset of ember-cli.

enter image description here

== Update 2: commenting I18N import and include constants in initialisation ==

I did do some refactoring and commented the I18N import that maybe is conflicting. I also included the constants inside the Ember app initialisation. see screenshot below for current version of app.js:

enter image description here

I didn't edit my Brocfile.jsas far as I know but decided to include a screenshot of it anyway because maybe it contains a bug.. you never know..

enter image description here

I hope someone knows a solution for this problem or can point me in the right direction. If you need more information don't hesitate to ask!

Thanks in advance,

Alexander Jeurissen

Upvotes: 5

Views: 1209

Answers (1)

AWM
AWM

Reputation: 1140

As collaboratively (see discussion) traced:

Use

Ember.Application.extend

instead of

Ember.Application.create

in your app\app.js (like in https://github.com/ember-cli/ember-cli/blob/master/blueprints/app/files/app/app.js).

Upvotes: 4

Related Questions