Angular 9升级CompilerFactory错误

时间:2020-05-20 22:55:38

标签: angular angular8 angular9 angular-ivy angular-upgrade

根据官方升级,我将角钢从8.2.2升级到9.1.8

Angular CLI: 9.1.6
Node: 12.16.1
OS: win32 x64

Angular: 9.1.8
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

-----------------------------------------------------------
@angular-devkit/architect         0.901.6
@angular-devkit/build-angular     0.901.6
@angular-devkit/build-optimizer   0.901.6
@angular-devkit/build-webpack     0.901.6
@angular-devkit/core              9.1.6
@angular-devkit/schematics        9.1.6
@angular/cli                      9.1.6
@ngtools/webpack                  9.1.6
@schematics/angular               9.1.6
@schematics/update                0.901.6
rxjs                              6.5.5
typescript                        3.6.4
webpack                           4.42.0

我在CompilerFactory上遇到错误

Uncaught NullInjectorError: StaticInjectorError(Platform: core)[CompilerFactory]: 
  NullInjectorError: No provider for CompilerFactory!

下面是main.ts文件

platformBrowserDynamic().bootstrapModule(AppModule).catch(err => console.log(err));

我在线检查了一下,因为角度9支持常春藤,所以platformBrowserDynamic()应该更改为platformBrowser()。我将main.ts更改为

 platformBrowser().bootstrapModule(AppModule).catch(err => console.log(err));

但是对于CompilerFactory错误仍然获得相同的No提供程序。 然后将main.ts更改为以下

 platformBrowser().bootstrapModuleFactory(<any>AppModule).catch(err => console.log(err));

并收到其他错误

Uncaught TypeError: Cannot read property 'name' of undefined

以下是在angular.json文件中的angular 9上添加的差异

 "options": {
            "aot": true,
}
   "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb"
                }
              ],
}

0 个答案:

没有答案