Application died in status UNMOUNTING: Cannot read property 'injector' of undefined

6.9k Views Asked by At

I am building microfrontend using Single-Spa-Angular library. I have created three different child app using "ng add single-spa-angular" and two of the app working fine, but one app showing below error:

Uncaught app2: Application 'app2' died in status UNMOUNTING: Cannot read property 'injector' of undefined
    at http://<HOSTNAME>:4202/main.js:204363:53

and

Uncaught app2: Application 'app2' died in status SKIP_BECAUSE_BROKEN: In this configuration Angular requires Zone.js
    at new NgZone (http://<HOST>:4202/main.js:68725:19)
    at getNgZone (http://<HOST>:4202/main.js:69414:13)
    at PlatformRef../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModuleFactory (http://<HOST>:4202/main.js:69312:22)
    at http://<HOST>:4202/main.js:69356:59

can any one help me out.

Thanks Shashi Bhushan Verma

2

There are 2 best solutions below

1
Govinda Rathi On BEST ANSWER

I was facing the same issue. Add the following line in your main.single-spa.ts file:

import 'zone.js/dist/zone';

This seemed to work for me.

0
Md Rafee On

You can alternatively add zone.js in the root-config.js file as script like the following.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/zone.min.js"></script>

As official single-spa documentation says

The preferred way to ensure only one instance of ZoneJS is loaded on your page is with a script tag in your root-config's HTML file. You should load ZoneJS upfront a single time, before loading SystemJS or any of your microfrontends.

For your reference docuementation