# Ionic 5 upgrade issue

**URL:** <https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223>\
**Category:** Ionic Framework\
**Created:** [February 12, 2020, 7:43pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223 "2020-02-12T19:43:57Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![andyhb](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@andyhb](https://forum.ionicframework.com/u/andyhb)\
**Post date:** [February 12, 2020, 7:43pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/1 "2020-02-12T19:43:57Z")

</div>

Just upgraded my project to Ionic 5 and also update angular to version 9, now my project won’t launch I get the following error: -

```auto
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:16082)
    at getInjectableDef (core.js:362)
    at injectableDefOrInjectorDefFactory (core.js:16834)
    at providerToFactory (core.js:16920)
    at providerToRecord (core.js:16904)
    at R3Injector.processProvider (core.js:16720)
    at core.js:16699
    at core.js:1367
    at Array.forEach (<anonymous>)

```

---

<div class="post-metadata">

**Author:** ![andyhb](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@andyhb](https://forum.ionicframework.com/u/andyhb)\
**Post date:** [February 12, 2020, 7:48pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/2 "2020-02-12T19:48:30Z")

</div>

if I change aot: true to aot: false in my angular.json file it all works again, which seems to contradict the message 😕

---

<div class="post-metadata">

**Author:** ![andyhb](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@andyhb](https://forum.ionicframework.com/u/andyhb)\
**Post date:** [February 12, 2020, 7:58pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/3 "2020-02-12T19:58:07Z")

</div>

I compared the previous angular.json and that didn’t have aot: true in that location so I removed it and now everything serves. Whether this will work when deployed to a device is anybodies guess!

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [February 12, 2020, 9:08pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/4 "2020-02-12T21:08:55Z")

</div>

Can you post the `devDependencies` stanza of your `package.json`?

---

<div class="post-metadata">

**Author:** ![Ionic37](https://avatars.discourse-cdn.com/v4/letter/i/f17d59/32.png) [@Ionic37](https://forum.ionicframework.com/u/Ionic37)\
**Post date:** [February 13, 2020, 4:46pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/5 "2020-02-13T16:46:20Z")

</div>

I had the same issue but left angular.json alone. I changed main.ts to add import ‘@angular/compiler’; with the imports at the top and I can now do ionic serve. Didn’t have this issue pre Angular 9 and with Ionic 4.

---

<div class="post-metadata">

**Author:** ![yuhai2017](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/yuhai2017/32/116046_2.png) [@yuhai2017](https://forum.ionicframework.com/u/yuhai2017)\
**Post date:** [February 14, 2020, 8:01am UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/6 "2020-02-14T08:01:44Z")

</div>

Wat to add `import '@angular/compiler';` in `main.ts` file.

---

<div class="post-metadata">

**Author:** ![sagrawal](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sagrawal/32/130650_2.png) [@sagrawal](https://forum.ionicframework.com/u/sagrawal)\
**Post date:** [February 15, 2020, 12:11pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/7 "2020-02-15T12:11:39Z")

</div>

I upgraded my Ionic application to Ionic 5 the day of the release as soon as I saw their [tweet](https://twitter.com/snagrawal11/status/1227468711361220617) and I had the same issue.

See my answer here [https://stackoverflow.com/questions/60183056/ionic-5-with-angular-9-angular-jit-compilation-failed-angular-compiler-not/60183174#60183174](https://stackoverflow.com/questions/60183056/ionic-5-with-angular-9-angular-jit-compilation-failed-angular-compiler-not/60183174#60183174)

Adding `import '@angular/compiler'; ` in `main.ts` file worked but hoping the Ionic team will resolve this issue.

---

<div class="post-metadata">

**Author:** ![sagrawal](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sagrawal/32/130650_2.png) [@sagrawal](https://forum.ionicframework.com/u/sagrawal)\
**Post date:** [February 15, 2020, 12:28pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/8 "2020-02-15T12:28:17Z")

</div>

Yes, that will work once you deploy it as app. The AOT flag was earlier used to comes into action only when you build the app with `--prod` flag in for production build but since Angular 9 , it is now also enabled for development mode.

This helps catching the code errors sooner in development mode only. But someone Ionic 5 is having some issue with that flag for development. So that is fine. Check my other comment for solutions.

---

<div class="post-metadata">

**Author:** ![andyhb](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@andyhb](https://forum.ionicframework.com/u/andyhb)\
**Post date:** [February 20, 2020, 7:58pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/9 "2020-02-20T19:58:02Z")

</div>

Came back to my project today, updated Ionic and now nothing works again…

```auto
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @angular-devkit/core@~8.2.14.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'ionic-selectric'
npm ERR! notarget

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/andy/.npm/_logs/2020-02-20T19_56_59_017Z-debug.log

```

---

<div class="post-metadata">

**Author:** ![andyhb](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@andyhb](https://forum.ionicframework.com/u/andyhb)\
**Post date:** [February 20, 2020, 8:17pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/10 "2020-02-20T20:17:29Z")

</div>

Crikey I went through and ran

npm install @latest

On everything I could see for both angular and ionic and then the dependencies that came and now it’s working again!!

I there not a quick and easy way of just running command that updates your Ionic project to the latest compatible software versions?

---

<div class="post-metadata">

**Author:** ![AndrWeisR](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@AndrWeisR](https://forum.ionicframework.com/u/AndrWeisR)\
**Post date:** [March 10, 2020, 4:26am UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/12 "2020-03-10T04:26:19Z")

</div>

I’ve upgraded from Ionic 4/Angular 7 to Ionic 5/Angular 9, and I’m running my app in the **Android emulator** (ionic serve is working OK).

Nothing’s helping me. I had “aot: true” in my angular.json - removed them, but still got the error. I added `import '@angular/compiler';` to my `main.ts` - didn’t help.

I still get:

```auto
[INFO:CONSOLE(3002)] "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.", source: http://localhost/main-es2015.js (3002)

```

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [March 10, 2020, 7:41pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/13 "2020-03-10T19:41:17Z")

</div>

> [@AndrWeisR](#):
>
> I’ve upgraded from Ionic 4/Angular 7 to Ionic 5/Angular 9

Did you follow [the Angular upgrade process/guide](https://angular.io/guide/updating-to-version-9)?

---

<div class="post-metadata">

**Author:** ![AndrWeisR](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@AndrWeisR](https://forum.ionicframework.com/u/AndrWeisR)\
**Post date:** [March 10, 2020, 10:18pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/14 "2020-03-10T22:18:22Z")

</div>

I did… Now it’s working. After fiddling around with aot options and imports, and then I thought reverting all of my changes, I’m not sure what made it start working.

---

<div class="post-metadata">

**Author:** ![AndrWeisR](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@AndrWeisR](https://forum.ionicframework.com/u/AndrWeisR)\
**Post date:** [March 26, 2020, 3:10am UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/15 "2020-03-26T03:10:51Z")

</div>

I’m back to square 1. My production/release build works OK. I’m trying to get a test configuration working (I copied my “production” configuration in angular.json and renamed it to “uat”, and left “aot” true). When I build with `ionic cordova build android --configuration uat`, and run it on the emulator, I get the same old errors:

```auto
Line 1 : 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.

```

I get this whether aot is true or false in my angular.json for my uat configuration. I’ve upgraded all of my ionic-native packages to the latest. Adding an explicit `import '@angular/compiler';` changes nothing.

Edit: I got it working by setting _both_ aot and buildOptimizer to false in my angular.json’s “uat” build config. The conclusion I draw from this is that you can’t use aot in a non-production build. Whyyyy?

Edit2: Now my prod build doesn’t work and is giving me the error. I have to set aot and buildOptimizer to false for prod builds as well. What fresh hell is this?

---

<div class="post-metadata">

**Author:** ![salah99](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@salah99](https://forum.ionicframework.com/u/salah99)\
**Post date:** [June 9, 2020, 8:43am UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/16 "2020-06-09T08:43:02Z")

</div>

I am also getting the same error with ionic 5 and angular 9.

This is crazy and no solution mentioned above ever worked except setting aot and buildoptimizer to false.

My application is slow because of this.

I really hope the ionic team will fix this issue it’s embarassing!!

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [June 9, 2020, 7:04pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/17 "2020-06-09T19:04:21Z")

</div>

It’s going to be challenging to say much without access to code that reproduces your problem. If you don’t wish to publicize the entire app, can you create a publicly-accessible stripped-down repository that displays the problem?

If it’s any motivation, it’s conceivable that even attempting to go through this process will show you that you’ve got a particular problematic dependency.

---

<div class="post-metadata">

**Author:** ![mikrochipkid](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mikrochipkid/32/116956_2.png) [@mikrochipkid](https://forum.ionicframework.com/u/mikrochipkid)\
**Post date:** [June 9, 2020, 7:23pm UTC](https://forum.ionicframework.com/t/ionic-5-upgrade-issue/183223/18 "2020-06-09T19:23:56Z")

</div>

I upgraded project a project with no problems in my first try. Removed changes and start from scratch. this time make sure to follow the upgrade guide provided by the Ionic team.
