升级到Angular 9后,没有CompilerFactory的提供程序

时间:2020-05-19 15:44:41

标签: angular angular8 ivy angular9 angular-upgrade

从8升级到9后,出现此错误

Uncaught NullInjectorError: StaticInjectorError(Platform: core)[CompilerFactory]:

NullInjectorError: No provider for CompilerFactory!

下面是我的main.ts的代码

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

if (environment.production) {
  enableProdMode();
}
  platformBrowserDynamic().bootstrapModule(AppModule).catch(err => console.log(err));

1 个答案:

答案 0 :(得分:0)

带有Ivy的Angular v9不再具有ngFactory文件 试试这个:

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

或者尝试引导 ModuleNgFactory