admin管理员组

文章数量:1023815

I have an Angular application, but I am not understanding what the piler is telling me on why the application can't build. These are the errors that I'm getting from the piler:

ERROR in src/app/list-items/list-itemsponent.ts:9:14 -
error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

Is it missing an @NgModule annotation?

9 export class ListItemsComponent implements OnInit {
               ~~~~~~~~~~~~~~~~~~
src/app/not-found/not-foundponent.ts:8:14 - error NG6002: Appears in the NgModule.imports of AppModule, but could
not be resolved to an NgModule class.

Is it missing an @NgModule annotation?

8 export class NotFoundComponent implements OnInit {
               ~~~~~~~~~~~~~~~~~

This is my list-itemsponent.ts file:

import { Component, OnInit, NgModule } from '@angular/core';

@Component({
  selector: 'app-list-items',
  templateUrl: './list-itemsponent.html',
  styleUrls: ['./list-itemsponent.css']
})
export class ListItemsComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
  }
}

This is my not-foundponent.ts file:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-not-found',
  templateUrl: './not-foundponent.html',
  styleUrls: ['./not-foundponent.css']
})
export class NotFoundComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
  }
}

Here is my app.module.ts file:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './appponent';
import { HttpClientModule } from '@angular/mon/http';  
import { ItemService } from './items.service';
import { NewItemFormComponent } from './new-item-form/new-item-formponent';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { NavigationMenuComponent } from './navigation-menu/navigation-menuponent';
import { ListItemsComponent } from './list-items/list-itemsponent';
import { NotFoundComponent } from './not-found/not-foundponent';
import { BrowserModule } from '@angular/platform-browser';

const appRoutes: Routes = [ {
  path: '',                     //default ponent to display
   ponent: ListItemsComponent
 },       {
   path: 'addItem',         //when items added 
   ponent: NewItemFormComponent
 },       {
   path: 'listItems',       //when items listed
   ponent: ListItemsComponent
 },       {
   path: '**',                 //when path cannot be found
   ponent: NotFoundComponent
 }
];

@NgModule({
  declarations: [
    AppComponent,
    NewItemFormComponent,
    NavigationMenuComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    MatFormFieldModule,
    MatInputModule,
    MatButtonModule,
    MatIconModule,
    MatMenuModule,
    BrowserAnimationsModule,
    FormsModule,
    RouterModule.forRoot(appRoutes),
    ListItemsComponent,
    NotFoundComponent
  ],

  providers: [ItemService],
  bootstrap: [AppComponent]
})
export class AppModule { }

Does anyone happen to understand what the piler is trying to tell me about NgModule?

I have an Angular application, but I am not understanding what the piler is telling me on why the application can't build. These are the errors that I'm getting from the piler:

ERROR in src/app/list-items/list-items.ponent.ts:9:14 -
error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

Is it missing an @NgModule annotation?

9 export class ListItemsComponent implements OnInit {
               ~~~~~~~~~~~~~~~~~~
src/app/not-found/not-found.ponent.ts:8:14 - error NG6002: Appears in the NgModule.imports of AppModule, but could
not be resolved to an NgModule class.

Is it missing an @NgModule annotation?

8 export class NotFoundComponent implements OnInit {
               ~~~~~~~~~~~~~~~~~

This is my list-items.ponent.ts file:

import { Component, OnInit, NgModule } from '@angular/core';

@Component({
  selector: 'app-list-items',
  templateUrl: './list-items.ponent.html',
  styleUrls: ['./list-items.ponent.css']
})
export class ListItemsComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
  }
}

This is my not-found.ponent.ts file:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-not-found',
  templateUrl: './not-found.ponent.html',
  styleUrls: ['./not-found.ponent.css']
})
export class NotFoundComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
  }
}

Here is my app.module.ts file:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.ponent';
import { HttpClientModule } from '@angular/mon/http';  
import { ItemService } from './items.service';
import { NewItemFormComponent } from './new-item-form/new-item-form.ponent';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { NavigationMenuComponent } from './navigation-menu/navigation-menu.ponent';
import { ListItemsComponent } from './list-items/list-items.ponent';
import { NotFoundComponent } from './not-found/not-found.ponent';
import { BrowserModule } from '@angular/platform-browser';

const appRoutes: Routes = [ {
  path: '',                     //default ponent to display
   ponent: ListItemsComponent
 },       {
   path: 'addItem',         //when items added 
   ponent: NewItemFormComponent
 },       {
   path: 'listItems',       //when items listed
   ponent: ListItemsComponent
 },       {
   path: '**',                 //when path cannot be found
   ponent: NotFoundComponent
 }
];

@NgModule({
  declarations: [
    AppComponent,
    NewItemFormComponent,
    NavigationMenuComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    MatFormFieldModule,
    MatInputModule,
    MatButtonModule,
    MatIconModule,
    MatMenuModule,
    BrowserAnimationsModule,
    FormsModule,
    RouterModule.forRoot(appRoutes),
    ListItemsComponent,
    NotFoundComponent
  ],

  providers: [ItemService],
  bootstrap: [AppComponent]
})
export class AppModule { }

Does anyone happen to understand what the piler is trying to tell me about NgModule?

Share Improve this question edited Apr 13, 2020 at 13:37 j3ff 6,1398 gold badges43 silver badges54 bronze badges asked Apr 12, 2020 at 20:28 libracornlibracorn 3174 silver badges10 bronze badges 2
  • Please share the code from your app.modules.ts the error is most likely there. – kacase Commented Apr 12, 2020 at 20:36
  • Hi there, added above. – libracorn Commented Apr 12, 2020 at 20:41
Add a ment  | 

1 Answer 1

Reset to default 4

Remove both ponents from the imports section in your app.modules file and move them to declarations.

You are not creating a custom module; you are only creating a ponent. Import it the correct way and you should not have any more problems.

I also suggest you use the angular cli generator to generate new ponents.

ng generate ponent test

I have an Angular application, but I am not understanding what the piler is telling me on why the application can't build. These are the errors that I'm getting from the piler:

ERROR in src/app/list-items/list-itemsponent.ts:9:14 -
error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

Is it missing an @NgModule annotation?

9 export class ListItemsComponent implements OnInit {
               ~~~~~~~~~~~~~~~~~~
src/app/not-found/not-foundponent.ts:8:14 - error NG6002: Appears in the NgModule.imports of AppModule, but could
not be resolved to an NgModule class.

Is it missing an @NgModule annotation?

8 export class NotFoundComponent implements OnInit {
               ~~~~~~~~~~~~~~~~~

This is my list-itemsponent.ts file:

import { Component, OnInit, NgModule } from '@angular/core';

@Component({
  selector: 'app-list-items',
  templateUrl: './list-itemsponent.html',
  styleUrls: ['./list-itemsponent.css']
})
export class ListItemsComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
  }
}

This is my not-foundponent.ts file:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-not-found',
  templateUrl: './not-foundponent.html',
  styleUrls: ['./not-foundponent.css']
})
export class NotFoundComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
  }
}

Here is my app.module.ts file:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './appponent';
import { HttpClientModule } from '@angular/mon/http';  
import { ItemService } from './items.service';
import { NewItemFormComponent } from './new-item-form/new-item-formponent';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { NavigationMenuComponent } from './navigation-menu/navigation-menuponent';
import { ListItemsComponent } from './list-items/list-itemsponent';
import { NotFoundComponent } from './not-found/not-foundponent';
import { BrowserModule } from '@angular/platform-browser';

const appRoutes: Routes = [ {
  path: '',                     //default ponent to display
   ponent: ListItemsComponent
 },       {
   path: 'addItem',         //when items added 
   ponent: NewItemFormComponent
 },       {
   path: 'listItems',       //when items listed
   ponent: ListItemsComponent
 },       {
   path: '**',                 //when path cannot be found
   ponent: NotFoundComponent
 }
];

@NgModule({
  declarations: [
    AppComponent,
    NewItemFormComponent,
    NavigationMenuComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    MatFormFieldModule,
    MatInputModule,
    MatButtonModule,
    MatIconModule,
    MatMenuModule,
    BrowserAnimationsModule,
    FormsModule,
    RouterModule.forRoot(appRoutes),
    ListItemsComponent,
    NotFoundComponent
  ],

  providers: [ItemService],
  bootstrap: [AppComponent]
})
export class AppModule { }

Does anyone happen to understand what the piler is trying to tell me about NgModule?

I have an Angular application, but I am not understanding what the piler is telling me on why the application can't build. These are the errors that I'm getting from the piler:

ERROR in src/app/list-items/list-items.ponent.ts:9:14 -
error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

Is it missing an @NgModule annotation?

9 export class ListItemsComponent implements OnInit {
               ~~~~~~~~~~~~~~~~~~
src/app/not-found/not-found.ponent.ts:8:14 - error NG6002: Appears in the NgModule.imports of AppModule, but could
not be resolved to an NgModule class.

Is it missing an @NgModule annotation?

8 export class NotFoundComponent implements OnInit {
               ~~~~~~~~~~~~~~~~~

This is my list-items.ponent.ts file:

import { Component, OnInit, NgModule } from '@angular/core';

@Component({
  selector: 'app-list-items',
  templateUrl: './list-items.ponent.html',
  styleUrls: ['./list-items.ponent.css']
})
export class ListItemsComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
  }
}

This is my not-found.ponent.ts file:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-not-found',
  templateUrl: './not-found.ponent.html',
  styleUrls: ['./not-found.ponent.css']
})
export class NotFoundComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
  }
}

Here is my app.module.ts file:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.ponent';
import { HttpClientModule } from '@angular/mon/http';  
import { ItemService } from './items.service';
import { NewItemFormComponent } from './new-item-form/new-item-form.ponent';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { NavigationMenuComponent } from './navigation-menu/navigation-menu.ponent';
import { ListItemsComponent } from './list-items/list-items.ponent';
import { NotFoundComponent } from './not-found/not-found.ponent';
import { BrowserModule } from '@angular/platform-browser';

const appRoutes: Routes = [ {
  path: '',                     //default ponent to display
   ponent: ListItemsComponent
 },       {
   path: 'addItem',         //when items added 
   ponent: NewItemFormComponent
 },       {
   path: 'listItems',       //when items listed
   ponent: ListItemsComponent
 },       {
   path: '**',                 //when path cannot be found
   ponent: NotFoundComponent
 }
];

@NgModule({
  declarations: [
    AppComponent,
    NewItemFormComponent,
    NavigationMenuComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    MatFormFieldModule,
    MatInputModule,
    MatButtonModule,
    MatIconModule,
    MatMenuModule,
    BrowserAnimationsModule,
    FormsModule,
    RouterModule.forRoot(appRoutes),
    ListItemsComponent,
    NotFoundComponent
  ],

  providers: [ItemService],
  bootstrap: [AppComponent]
})
export class AppModule { }

Does anyone happen to understand what the piler is trying to tell me about NgModule?

Share Improve this question edited Apr 13, 2020 at 13:37 j3ff 6,1398 gold badges43 silver badges54 bronze badges asked Apr 12, 2020 at 20:28 libracornlibracorn 3174 silver badges10 bronze badges 2
  • Please share the code from your app.modules.ts the error is most likely there. – kacase Commented Apr 12, 2020 at 20:36
  • Hi there, added above. – libracorn Commented Apr 12, 2020 at 20:41
Add a ment  | 

1 Answer 1

Reset to default 4

Remove both ponents from the imports section in your app.modules file and move them to declarations.

You are not creating a custom module; you are only creating a ponent. Import it the correct way and you should not have any more problems.

I also suggest you use the angular cli generator to generate new ponents.

ng generate ponent test

本文标签: javascriptAngular application not building NgModuleStack Overflow