【问题标题】:Angular AOT compilation failedAngular AOT 编译失败
【发布时间】:2017-03-10 05:28:57
【问题描述】:

我需要尽快将网站投入生产,并正在研究 AOT 以提高性能(我的应用在 Chrome 上加载大约需要 3-4 秒,在 Firefox 上需要 8-10 秒,这对于生产来说是不可能的) .

我按照https://angular.io/docs/ts/latest/cookbook/aot-compiler.html 上的指南进行操作,但被编译部分卡住了...

如果我输入:node_modules/.bin/ngc -p tsconfig-aot.json,我会得到一个不错的“编译失败”,其中包含大约 10000 个错误的列表,比如这个:

Error at /myapp/aot/app/contact/admin/contact-list.component.ngfactory.ts:64:7: Supplied parameters do not match any signature of call target.

我无法解决所有问题,因为有些直接来自 Angular(我猜),例如:

Error at /myapp/node_modules/@angular/core/src/di/reflective_provider.d.ts:88:165: Cannot find name 'Map'.

编译失败是否与所有这些错误有关,如果我解决了这些错误,编译是否会通过?如果是的话,即使是 Angular 也会导致我提供的错误,这是否正常?

谢谢!

注意:我使用的是 Angular 2.1.1。

【问题讨论】:

    标签: angular typescript angular2-aot


    【解决方案1】:

    我和 kinkaz 在同一条船上。对我有用的是从 angular.io 网站在 AoT 教程中建议的 tsconfig-aot.json 文件中删除以下内容...

    删除,

    "typeRoots": [ “../../node_modules/@types/” ]

    来自 tsconfig-aot.json

    【讨论】:

      【解决方案2】:

      有兴趣的朋友:

      如果您有 Typescript 错误,编译器将失败(即使您忘记输入变量,例如public myVar; 会抛出错误,public myVar: any; 会通过)。

      不应出现角度错误,通过在我的 package.json 中添加此依赖项已为我解决了这个问题:

      "@types/core-js": "^0.9.34"

      【讨论】:

        猜你喜欢
        • 2020-09-03
        • 2017-03-28
        • 1970-01-01
        • 1970-01-01
        • 2018-02-15
        • 2018-01-29
        • 1970-01-01
        • 1970-01-01
        • 2018-02-14
        相关资源
        最近更新 更多