简体   繁体   中英

No provider for CompilerFactory after upgrade to Angular 9

After I upgrade from 8 to 9, I am getting this error

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

NullInjectorError: No provider for CompilerFactory!

below are the code for my 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));

Angular v9 with Ivy isn't have ngFactory files anymore Try this:

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

Or try to bootstrap ModuleNgFactory .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM