【发布时间】:2017-09-21 19:34:48
【问题描述】:
我的团队目前正在开发我们的第一个 Angular/Angular-cli 应用程序。虽然我们的项目使用 JIT 编译来构建和工作,但我们遇到了 IE 11 的性能问题,所以我想了解使用 AOT 时的 IE 性能(使用 --prod 参数构建)。不幸的是,构建失败了,由于缺乏经验,我不完全理解错误或如何处理它。
错误:
[ERROR] ERROR in Cannot determine the module for class BaseSopPanelComponent in /Users/brife/svn/lms/sop/branches/current/ng2/src/app/components/base-sop-panel/base-sop-panel.component.ts! Add BaseSopPanelComponent to the NgModule to fix it.
[ERROR] ERROR in ./src/main.ts
[ERROR] Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/brife/svn/lms/sop/branches/current/ng2/src'
[ERROR] resolve './$$_gendir/app/app.module.ngfactory' in '/Users/brife/svn/lms/sop/branches/current/ng2/src'
[ERROR] using description file: /Users/brife/svn/lms/sop/branches/current/ng2/package.json (relative path: ./src)
[ERROR] Field 'browser' doesn't contain a valid alias configuration
[ERROR] after using description file: /Users/brife/svn/lms/sop/branches/current/ng2/package.json (relative path: ./src)
[ERROR] using description file: /Users/brife/svn/lms/sop/branches/current/ng2/package.json (relative path: ./src/$$_gendir/app/app.module.ngfactory)
[ERROR] no extension
[ERROR] Field 'browser' doesn't contain a valid alias configuration
[ERROR] /Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory doesn't exist
[ERROR] .ts
[ERROR] Field 'browser' doesn't contain a valid alias configuration
[ERROR] /Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory.ts doesn't exist
[ERROR] .js
[ERROR] Field 'browser' doesn't contain a valid alias configuration
[ERROR] /Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory.js doesn't exist
[ERROR] as directory
[ERROR] /Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory doesn't exist
[ERROR] [/Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory]
[ERROR] [/Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory.ts]
[ERROR] [/Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory.js]
[ERROR] [/Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory]
BaseSopPanelComponent 是我们 6 或 7 个组件的基类。构造函数签名是:
constructor(public readonly dataService: SopDataService, public readonly name: string)
将 BaseSopPanelComponent 添加到 app.modules 后出现错误
[ERROR] ERROR in Can't resolve all parameters for BaseSopPanelComponent in /Users/brife/svn/lms/sop/branches/current/ng2/src/app/components/base-sop-panel/base-sop-panel.component.ts: ([object Object], ?).
[ERROR] ERROR in ./src/main.ts
[ERROR] Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/brife/svn/lms/sop/branches/current/ng2/src'
[ERROR] resolve './$$_gendir/app/app.module.ngfactory' in '/Users/brife/svn/lms/sop/branches/current/ng2/src'
[ERROR] using description file: /Users/brife/svn/lms/sop/branches/current/ng2/package.json (relative path: ./src)
[ERROR] Field 'browser' doesn't contain a valid alias configuration
[ERROR] after using description file: /Users/brife/svn/lms/sop/branches/current/ng2/package.json (relative path: ./src)
[ERROR] using description file: /Users/brife/svn/lms/sop/branches/current/ng2/package.json (relative path: ./src/$$_gendir/app/app.module.ngfactory)
[ERROR] no extension
[ERROR] Field 'browser' doesn't contain a valid alias configuration
[ERROR] /Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory doesn't exist
[ERROR] .ts
[ERROR] Field 'browser' doesn't contain a valid alias configuration
[ERROR] /Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory.ts doesn't exist
[ERROR] .js
[ERROR] Field 'browser' doesn't contain a valid alias configuration
[ERROR] /Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory.js doesn't exist
[ERROR] as directory
[ERROR] /Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory doesn't exist
[ERROR] [/Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory]
[ERROR] [/Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory.ts]
[ERROR] [/Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory.js]
[ERROR] [/Users/brife/svn/lms/sop/branches/current/ng2/src/$$_gendir/app/app.module.ngfactory]
[ERROR] @ ./src/main.ts 3:0-74
[ERROR] @ multi ./src/main.ts
我不知道如何从这里开始。提前感谢您的帮助。
【问题讨论】:
-
它的名字应该来自哪里?您需要一个注入令牌或工厂提供者。阅读 DI 文档。
-
你的模块声明中有 BaseSopPanelComponent 吗?
-
BaseSopPanelComponent 是基类,子类实例化时注入参数。 Angular 不需要注入参数
-
本来我没有,但是添加到模块列表时,Angular抱怨构造函数参数注入。
标签: angular angular-cli