无法列出惰性路由:Angular 更新后未知模块 AppModule

Hei*_*rme 8 angular

我没有在任何地方指定 app.module 上的惰性路由,但它向我抛出此错误并且无法编译:

ERROR in Failed to list lazy routes: Unknown module '/Users/heikopiirme/Documents/realNewClient/client/src/app/app.module#AppModule'.
Run Code Online (Sandbox Code Playgroud)

我使用铺设加载的唯一地方是在这里:

{
    path: 'logistics',
    loadChildren: () => import('./views/logistics/logistics.module').then(m => m.LogisticsModule),
    canActivate: [ AuthGuard, NgxPermissionsGuard ],
    data: {
      permissions: {
        only: [Role.logistics_manager],
        redirectTo: '/home'
      }
    }
  }
Run Code Online (Sandbox Code Playgroud)

这给了我一个错误,但在切换到新语法后它已修复。我应该如何为 AppModule 解决这个问题?

gre*_*reg 5

在将我的学习项目升级到 8 Like op 后,我得到了这个错误,我很惊讶地发现这个错误,因为我没有使用延迟加载。

我的问题是其中一个 IMPORT 语句是错误的。我终于偶然注意到了这一点。

import { HeroesComponent } from './Heroes/heroes1/heroes.component';
   and the error shows up

enableProdMode();

const routes: Routes = [
   { path: 'heroes', component: HeroesComponent },
Run Code Online (Sandbox Code Playgroud)

如果我将路径更正为(取出文件夹中的1,heroes1--> Heroes)

./Heroes/heroes/heroes.component
Run Code Online (Sandbox Code Playgroud)

错误消失并且应用程序编译。

这是一条疯狂的红鲱鱼。由于多种原因,从 7 迁移到 8 一直很困难。希望这对其他人有帮助。


Nor*_*tko 1

你不需要import(...),它更简单:

...
path: 'logistics', loadChildren: './views/logistics/logistics.module#LogisticsModule'
...
Run Code Online (Sandbox Code Playgroud)