找不到名称System angular 2 webpack 2

时间:2017-01-19 11:39:59

标签: angular webpack-2

我将加载的异步路由更改为如此。

import { Routes } from '@angular/router';

import { RoleModel, ConfigurationResolverService } from '../shared/services';

import { UnitMaintenancePage } from '../unit-maintenance.page/unit-maintenance.page'; import { TimeEntryPage } from '../time-entry.page/time-entry.page'; import { LayoutMainPage } from './layout-main.page'; import { DashboardPage } from '../dashboard.page/dashboard.page'; import { PayTypesPage } from '../pay-types.page/pay-types.page'; import { LayoutMainAuthGuardService } from './layout-main-auth-guard.service';

/**   * Here are the application routes   */

export const layoutMainRoutes: Routes = [
    {
        path: '',
        component: LayoutMainPage,
        canActivate: [LayoutMainAuthGuardService],
        data: { roles: [RoleModel.ADMIN] },
        // canActivate: [ActivateRouteGuardService],
        children: [
            {
                path: '',
                loadChildren: () => System.import('../dashboard.page/dashboard.module').then(module => module['DashboardModule'])
            },
            {
                path: 'holiday-maintenance',
                loadChildren: () => System.import('../holiday-maintenance.page/holiday-maintenance.module').then(module
=> module['HolidayMaintenanceModule'])
            },
            {
                path: 'unit-maintenance',
                loadChildren: () => System.import('../unit-maintenance.page/unit-maintenance.module').then(module
=> module['UnitMaintenanceModule'])
            },
            {
                path: 'time-entry',
                loadChildren: () => System.import('../time-entry.page/time-entry.module').then(module => module['TimeEntryModule'])
            },
            {
                path: 'shift-maintenance',
                loadChildren: () => System.import('../shift-maintenance.page/shift-maintenance.module').then(module
=> module['ShiftMaintenanceModule'])
            },
            {
                path: 'pay-types',
                loadChildren: () => System.import('../pay-types.page/pay-types.module').then(module => module['PayTypesModule'])
            },
            {
                path: 'category-maintenance',
                loadChildren: () => System.import('../category-maintenance.page/category-maintenance.module').then(module
=> module['CategoryMaintenanceModule'])
            },
            {
                path: 'employee-maintenance',
                loadChildren: () => System.import('../employee-maintenance.page/employee-maintenance.module').then(module
=> module['EmployeeMaintenanceModule'])
            },
            {
                path: 'employee-overrides',
                loadChildren: () => System.import('../employee-overrides.page/employee-overrides.module').then(module
=> module['EmployeeOverridesModule'])
            },
            {
                path: 'timekeeper-maintenance',
                loadChildren: () => System.import('../timekeeper.page/timekeeper.module').then(module => module['TimekeeperMaintenanceModule'])
            },
            {
                path: 'sub-category',
                loadChildren: () => System.import('../sub-category.page/sub-category.module').then(module
=> module['SubCategoryModule'])
            },
            {
                path: 'function-maintenance',
                loadChildren: () => System.import('../function-maintenance.page/function-maintenance.module').then(module
=> module['FunctionMaintenanceModule'])
            }
        ]
    } ];

Webpack建议这样做,但我仍然在检查时收到错误。

[at-loader] Checking finished with 12 errors
Error in bail mode: [at-loader] src\app\layout-main.page\layout-main.routes.ts:26:37
    Cannot find name 'System'.

我安装了@types/systemjs但它似乎没有影响它有没有人知道这个问题在哪里?

1 个答案:

答案 0 :(得分:0)

  

我删除了我的typings.json和typings文件夹,之后   重新安装一切。 Webpack现在有效,但我不明白为什么   typings文件夹与配置冲突,任何人都可以   解释原因?