角度2 AOT错误

时间:2017-04-09 14:41:03

标签: angular webpack

当我在我的应用程序中运行AOT编译时,出现此错误:

[254]...
[255] ./client/app/main/app.module.ngfactory.ts 942 bytes {0} [built] [failed] [1 error]
   [] -> factory:9ms building:292ms = 301ms
[256]...


ERROR in ./client/app/main/app.module.ngfactory.ts
Module parse failed: C:\Users\user\Documents\project\src\project\node_modules\angular2-router-loader\src\index.js!C:\Users\user\Documents\project\src\project\node_modules\awesome-typescript-loader\dist\entry.js!C:\Users\user\Documents\project\src\project\node_modules\angular2-template-loader\index.js!C:\Users\user\Documents\project\src\project\client\app
\main\app.module.ngfactory.ts Unexpected token (730:83)
You may need an appropriate loader to handle this file type.
|                     path: 'profile',
|                     component: import60.ProfileComponent,
|                     loadChildren: () => new Promise(function (resolve) {  (require as any).ensure([], function (require: any) {    resolve(require('..\\profile\\profile.module')['ProfileModule']);  });})
|                 }
|             ],
 @ ./client/app/main/main.aot.ts 6:29-62

有没有人知道导致此错误的原因是什么?感谢。

修改

app.module.ts

@NgModule({
        declarations: [
            AppComponent
        ],
        imports: [
            BrowserModule,
            CustomerModule,
            OrgModule,
            routing,
            SharedModule.forRoot(),
            AgmCoreModule.forRoot({
                apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
                libraries: ['places']
            })
        ],
        bootstrap: [AppComponent],
        providers: [
            {provide: APP_CONFIG, useValue: AppConfig}
        ]
    })
    export class AppModule {   }

编辑2:

错误中引用的路由文件。

const ORG_ROUTES: Routes = [
    { path: 'organisation', redirectTo: 'organisation/home', pathMatch: 'full', canActivate: [LoggedinGuard] },
    { path: 'home', component: Org_homeComponent, canActivate: [LoggedinGuard] },
    { path: 'profile', component: ProfileComponent,
        loadChildren: '../profile/profile.module#ProfileModule' }
];

export const org_routing = RouterModule.forChild(ORG_ROUTES);

0 个答案:

没有答案