Angular 没有可用于依赖项类型的模块工厂:ContextElementDependency

Angular 没有可用于依赖项类型的模块工厂:ContextElementDependency,angular,webpack,angular-cli,Angular,Webpack,Angular Cli,我正在用延迟加载的模块更改angular-4应用程序的结构,运行时遇到错误 ng build 错误: 错误:依赖项类型:ContextElementDependency没有可用的模块工厂 当我注释掉延迟加载的模块时,不会出现此错误 这是my package.json: 全球安装的设备包括(除其他外): 打字稿2.4.2 网页3.6.0 @angular/cli 1.4.2 我在GitHub上发现了一些问题线程,但没有解决方案。我试图重新安装webpack和@angular/cli。没有任何

我正在用延迟加载的模块更改angular-4应用程序的结构,运行时遇到错误

ng build
错误:

错误:依赖项类型:ContextElementDependency没有可用的模块工厂

当我注释掉延迟加载的模块时,不会出现此错误

这是my package.json:

全球安装的设备包括(除其他外):

  • 打字稿2.4.2
  • 网页3.6.0
  • @angular/cli 1.4.2
我在GitHub上发现了一些问题线程,但没有解决方案。我试图重新安装
webpack
@angular/cli
。没有任何帮助

对此有什么建议/经验/提示吗


这是我的
AppModule

const appRoutes: Routes = [

// These routes cause the compile-error (ng build)
  { path: "Finances", loadChildren: "./Finances/finances.module#FinancesModule" },
  { path: "Test", loadChildren: "./Test/test.module#TestModule" },
  { path: "Media", loadChildren: "./Media/media.module#MediaModule" },

//These routes work
  { path: "Dashboard", component: DashboardComponent },
  { path: "Error/:errorId", component: ErrorComponent },
  { path: "", pathMatch: "full", redirectTo: "Dashboard"},
  { path: "**", redirectTo: "/Error/http404" }
];
e、 g.
测试模块.ts

// imports

const testRoutes: Routes = [
    {
        path: "",
        component: IndexComponent,
    },
];

@NgModule({
    imports: [
        RouterModule.forChild(
            testRoutes
        ),
        HttpModule,
        CommonModule,
        FormsModule,
        SharedModule
    ],
    declarations: [
        IndexComponent
    ],
    bootstrap: [
        IndexComponent
    ]
})
export class TestModule {
}

您应该使用相同版本的角度相关性。因此,改变:

"@angular/compiler-cli": "4.2.4"


你能添加复制吗?至少添加延迟加载的配置routes@yurzui我添加了路由配置和一个延迟加载的子模块。为什么要使用
“@angular/compiler cli”:“4.2.4”
,而其他角度依赖项有
^4.2.4
版本?@yurzui这不是有意的,我将用
“^4.2.4”
@yurzui尝试一下谢谢!这就是问题所在…不平等的版本。。。如果你把它作为回复贴出来,我会把它标记为答案
"@angular/compiler-cli": "4.2.4"
"@angular/compiler-cli": "^4.2.4"