Angular : Error: Uncaught (in promise) at webpackAsyncContext (eval at ./src/$$_lazy_route_resource

后端 未结 10 632
独厮守ぢ
独厮守ぢ 2020-12-14 15:32

I\'m upgrading from Angular 4.0.0 to Angular 5.2.6

i\'m facing some problem to get lazy module loading working.

with

相关标签:
10条回答
  • 2020-12-14 15:57

    i have resolved this issue by upgrading mt angular-cli locally in the devDependenices (package.json) from 1.2.0 to 1.6.7

    0 讨论(0)
  • 2020-12-14 15:59

    I had exactly the same issue but simply restarting the nodes server (ng s) did the trick for me.

    As a rule of thumb: if angular starts behaving strange, first try to restart your nodes server

    0 讨论(0)
  • 2020-12-14 16:08

    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

    0 讨论(0)
  • 2020-12-14 16:08

    As mentioned in https://github.com/angular/angular-cli/issues/9488#issuecomment-368871510 it seems to work with ng serve --aot

    0 讨论(0)
提交回复
热议问题