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?
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"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With