inject() must be called from an injection context Angular Microapp module federation

41 Views Asked by At

I have an Angular app with some microapps in it using module federation. When I Log-In to it and try to access those microapps "SOMETIMES RANDOMLY" I get the inject() must be called from an injection context error and that route is not opened, I have not been able to find the root cause since it happens sometimes.

I have 2 libraries created for the project, so 2 extra package.json all the 3 angular/core versions are same ie 12.2.0.

Have tried multiple solutions on stackoverflow with heading inject() must be called from an injection context, such as adding preservesymlink true, adding "@angular/": [ "./node_modules/@angular/" ], this in tsconfig.json,

Tried making singlton to false, giving requiredVersion as 12.2.0 instead of auto

Also tried adding this in index.html

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="0" /> <meta name="cache-control" content="no-cache" />

stack trace of the error

enter image description here

the app-routing

enter image description here

Here are some of the settings of my app.

enter image description here

0

There are 0 best solutions below