Angular 5 lazy loading Error: Cannot find module

前端 未结 8 1856
栀梦
栀梦 2021-01-02 08:13

I would like to use lazy loading but I can not understand why it does not work, it gives me error \"Cannot find module\".
This is my environment:
- Angular 5.2.1

相关标签:
8条回答
  • 2021-01-02 08:44

    I have also faced the same issue while loading my module I was getting this error Error: Cannot find module 'app/users/users.module' Then after figuring out it was error related to the path This solution works for me hope it help anyone In the route add this path

    {
       path: 'users',
       loadChildren: '../app/users/users.module#UsersModule'
     }
    

    Figure out the path of your module folder like folder or ./folder or ../folder

    Happy Coding!!

    0 讨论(0)
  • 2021-01-02 08:48

    Supposing this is AppModule that handles lazyloading and the features of your system are of the same tree as it is:

    routes: Routes = [
        {
            path: 'files-pannel',
            loadChildren: () => import('./module-folder/module-name.module').then(m => m.ModuleName)
        }
    ];
    
    0 讨论(0)
提交回复
热议问题