atschaal
atschaal

Reputation: 355

ember-cli migration: global app module import

I'm having some slight ember-cli migration difficulties with the global application variable.

In project/app/app.js I define App as:

var App;
Ember.MODEL_FACTORY_INJECTIONS = true;
App = Ember.Application.extend({
  modulePrefix: config.modulePrefix,
  podModulePrefix: config.podModulePrefix,
  Resolver: Resolver
});

Then in a separate controller, project/app/controllers/auth.js, I attempt to access App using the following statement:

import Ember from 'ember';
import App from '../app.js';

This results in an extremely odd error from when running the application. I receive the following error from the Chrome inspector (or Firebug):

Uncaught Error:  Could not find module 'project/app.js' imported 
from 'project/controllers/auth'

At first glance this appears to be a path error in my import statement. However, efforts to fix the path have proven useless. Then I also noticed that the imported portion of the error was not including the correct path either! It should read project/app/controllers/auth but instead reads project/controllers/auth. I'm quite confused as to what's happening here.

Please let me know if I can provide more details at all, thanks so much!

Upvotes: 1

Views: 211

Answers (1)

GJK
GJK

Reputation: 37369

Your issue is that the module path contains the .js extension. Change the path to just '../app' and it will work just fine.

Upvotes: 3

Related Questions