【问题标题】:Angular --prod build failingAngular --prod 构建失败
【发布时间】: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


【解决方案1】:

已解决。组件基类被错误地注释为@Component。没有与组件关联的 UI,在确定 @Components 可以扩展非组件后,我删除了允许 --prod 构建成功完成的注释

【讨论】:

    猜你喜欢
    • 2018-12-25
    • 2019-01-10
    • 1970-01-01
    • 2017-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-20
    相关资源
    最近更新 更多