' NgModule'仅指类型,但在此处用作值

时间:2018-01-30 09:51:31

标签: angular

我不知道为什么我在这个模块中收到此错误:

import { NgModule } from '@angular/compiler/src/core';
import { AdminHeaderComponent } from '../admin/admin-header/admin-header.component';
import { AdminLeftSideComponent } from '../admin/admin-left-side/admin-left-side.component';
import { AdminContentComponent } from '../admin/admin-content/admin-content.component';
import { AdminFooterComponent } from '../admin/admin-footer/admin-footer.component';
import { AdminControlSidebarComponent } from '../admin/admin-control-sidebar/admin-control-sidebar.component';
import { AdminDashboard1Component } from '../admin/admin-dashboard1/admin-dashboard1.component';
import { AdminDashboard2Component } from '../admin/admin-dashboard2/admin-dashboard2.component';
import { CommonModule } from '@angular/common';
import { AdminComponent } from "../admin/admin.component";
import { StarterRoutingModule } from "./starter-routing/starter-routing.module";
import { StarterComponent } from "./starter.component";


@NgModule({
  imports: [
    CommonModule,
    StarterRoutingModule
  ],
  declarations: [
    AdminComponent,
    AdminHeaderComponent,
    AdminLeftSideComponent,
    AdminContentComponent,
    AdminFooterComponent,
    AdminControlSidebarComponent,
    AdminDashboard1Component,
    AdminDashboard2Component
  ],
  exports: [StarterComponent]
})
export class StarterModule { }

我有一个非常相同的模块,它可以正确编译。

这是一种非常奇怪的行为......以前从未发生过。

感谢支持

2 个答案:

答案 0 :(得分:2)

NgModule而不是@angular/core导入@angular/compiler/src/core。在IDE使用的自动导入期间给出了错误的路径。

import { NgModule } from '@angular/core';

答案 1 :(得分:2)

尝试替换此行:

import { NgModule } from '@angular/compiler/src/core';

使用:

import { NgModule } from '@angular/core';