Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 9 Unhandled Promise rejection: Angular JIT compilation failed error

Tags:

angular

I upgraded our app to Angular 9 yet in production testing I am getting this error. I am serving my app with the command ng serve --optimization=true --aot=true --prod before I deploy this to production and its just not working

Unhandled Promise rejection: 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. ; Zone: <root> ;

This is pointing to my polyfills.ts

I have added import "@angular/compiler to the top of my main.ts file with no luck.

I have also removed all the imports from polyfill except for zone.js and still get the error.

What does this mean and how can it be fixed?

like image 509
Terrance Jackson Avatar asked Dec 17 '25 19:12

Terrance Jackson


1 Answers

You need to import '@angular/compiler' at the very top of your main.ts file but since you already have that then

You have to run this in your package.json

scripts{
"postinstall": "ngcc --properties es5 browser module main --first-only"
}
like image 136
CodeMan03 Avatar answered Dec 20 '25 11:12

CodeMan03



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!