Uncaught ReferenceError: _EmberApplication is not defined

Fellow Devs,

I got into this error when running the app recently, it’s pointing to app.js but i don’t have any recent change in it.

I cleared my node_modules, yarn.lock, /tmp, /dist and rerun the application to fetch my latest addon changes.

app.js

import Application from '@ember/application';
....

const App = Application.extend({
  ....
});

export default App; 

Thanks!

I just created a new app to demonstrate the issue. https://github.com/selva-v/demo-app_EmberApplication-error

I think you’re hitting this bug:

That problem has started occurring in more cases very recently due a babel release. I think there is a fix coming imminently.

ember-cli-babel@7.20.1 was just released, and should fix the underlying issue.

Thank you @rwjblue and @ef4 ember-cli-babel@7.20.1 solves the problem. Would it be good idea to upgrade the ember version to 3.16.0 which is also solving the problem in my case.

but it is not working for me i’m using ember version 3.4 and another app 2.15 app. Both app are not working.

@Karthikeyan_Subbiah Those versions no longer maintained. Perhaps upgrade to 3.8 at least.

I think ember-cli-babel is broadly backward compatible though. While updating is always good, I don’t think people need to update ember to get this bugfix.

any other solutions? updating the ember to new version is a challenge and will not happen immediately. any quick fix?

That’s what I’m saying: you don’t need to upgrade ember. You just need to upgrade ember-cli-babel. It’s a separate dependency in package.json.

I just checked and the very newest ember-cli-babel works fine with a new ember 2.15 app.

I tried that, i’m getting the below error.

_Ember$run is not defined ReferenceError: _Ember$run is not defined

In which file?

I suspect one of your addons is still using an older ember-cli-babel that has the bug.

FWIW, another set of fixes has been released in ember-cli-babel@7.20.5 that fix another category of bugs (this issue was actually introduced in 7.20.1).

Also, you do not need to be on the latest ember-cli-babel to get these fixes, you need the latest babel-plugin-ember-modules-api-polyfill. The easiest way to get that is to update your ember-cli-babel version, but you can update it in other ways as well (including for transitive dependencies that you do not directly have control over).

For example, yarn users can do the following:

  • Add the following to your package.json’s resolutions field:
{
  "resolutions": {
    "babel-plugin-ember-modules-api-polyfill": "^2.13.4",
  }
}
  • run yarn install
  • remove the added resolution
  • run yarn install

This will ensure that all versions of ember-cli-babel@6.9.0 have the latest version that includes the required fixes.

1 Like