Ionic 5 with Angular 9 – Angular JIT compilation error: “@ angular / compiler” not loaded

0
261
# To update to Ionic 5
npm install @ionic/angular@latest @ionic/angular-toolkit@latest --save-exact --save

# To update to Angular 9
ng update @angular/core @angular/cli

But when I did ionic serve, I started getting the following error:

Error: Angular JIT compilation failed: '@angular/compiler' not loaded!
  - JIT compilation is discouraged for production use-cases! Consider AOT mode instead.
  - Did you bootstrap using '@angular/platform-browser-dynamic' or '@angular/platform-server'?
  - Alternatively provide the compiler with 'import "@angular/compiler";' before bootstrapping.
    at getCompilerFacade (core.js:610)
    at Function.get (core.js:16065)
    at getInjectableDef (core.js:362)
    at injectableDefOrInjectorDefFactory (core.js:16816)

I ran into several Angular GitHub issues:

  1. https://github.com/angular/angular-cli/issues/16873
  2. https://github.com/angular/angular/issues/32466

They say include import '@angular/compiler';in file main.ts, but when I mapped one of my other Angular 9 apps (which I recently updated) I don’t see any such configurations there.

SOLUTION

Add import '@angular/compiler';to file main.ts.

LEAVE A REPLY

Please enter your comment!
Please enter your name here