[英]ember-cli migration: global app module import
I'm having some slight ember-cli migration difficulties with the global application variable. 我对全局应用程序变量有一些轻微的ember-cli迁移困难。
In project/app/app.js
I define App as: 在
project/app/app.js
我将App定义为:
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: 然后在一个单独的控制器
project/app/controllers/auth.js
,我尝试使用以下语句访问App
:
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):
我从Chrome检查器(或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. 乍一看,这似乎是我的import语句中的路径错误。 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
. 它应该读取
project/app/controllers/auth
,而是读取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! 如果我能提供更多详细信息,请告诉我,非常感谢!
Your issue is that the module path contains the .js
extension. 您的问题是模块路径包含
.js
扩展名。 Change the path to just '../app'
and it will work just fine. 将路径更改为
'../app'
,它会正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.