Angular : Error: Uncaught (in promise) at webpackAsyncContext (eval at ./src/$$_lazy_route_resource
Do not import your lazy loaded module within your main app.module.ts. This will cause a circular dependency and throw the error you are receiving.
I have changed the order of imports in my app.module.ts
as mentioned here
So you need to have it for example like this:
imports: [
BrowserModule,
FormsModule,
HeroesModule,
AppRoutingModule
]
The most important is to have First BrowserModule
and at the end AppRoutingModule
.
Solution 1
Imports order does matter so import lazy loaded module
in top and router module
in the last place. Because we are doing lazy loading, that lazy-loaded module has to exist before we do routing.
imports: [
BrowserModule,
HeroModule, // Lazy-loaded module
AppRoutingModule
],
Solution 2
Usually Angular CLI
will import the module
to app-module
when it was generated. so make sure lazy-loaded
module was not imported in app-module