EXCEPTION: Uncaught (in promise): Error: Cannot find module 'app/home/home.module'

后端 未结 11 2470
遇见更好的自我
遇见更好的自我 2021-01-01 12:37

I\'m trying to lazy load Angular 2 modules with the router, and I\'m having this error:

error_handler.js:50 EXCEPTION: Uncaught (in promise): Error: C

11条回答
  •  难免孤独
    2021-01-01 12:53

    I landed on this question with very similar symptoms and context, so it seems useful to remark that this answer to another question helped me out.

    In my specific case, I was somewhat following the lazy feature modules docs, and I even faithfully tried to replicate the associated StackBlitz example code. For some reason that example gets away with:

    loadChildren: 'app/customers/customers.module#CustomersModule'
    

    And even though my Angular CLI (v6) based experiment had similar folder structure, I needed to do either this:

    // Full path including `src` at the start:
    loadChildren: 'src/app/customers/customers.module#CustomersModule'
    

    or this:

    // Relative path from the `app-routing.module.ts` file:
    loadChildren: './customers/customers.module#CustomersModule'
    

    No clue why the StackBlitz example gets away with the first code example, but the other two both make sense and work for me when doing ng serve.

提交回复
热议问题