Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

angular - ng build --prod Cannot determine the module for class X! Add ThreadListTabsComponent to the NgModule to fix it

I'm trying to build my Angular 5 app, and I'm getting the error:

Cannot determine the module for class ThreadListTabsComponent in /home/brightwater/Differ/src/app/thread-lists/thread-lists.component.ts! Add ThreadListTabsComponent to the NgModule to fix it.

This is confusing because I'm importing the offending component in the module:

thread-lists.module.ts:

import { OtherModules } from './modules-everywhere';
import { NgModule }      from '@angular/core'

import { SomeOtherComponents }  from './other-components.component';
import { ThreadListTabsComponent } from './thread-list-tabs.component';

@NgModule({
  imports: 
  [ 
    OtherModules
  ],
  declarations: [
    OtherComponents,
    ThreadListTabsComponent
  ],
  exports: [
    OtherComponents,
    ThreadListTabsComponent
  ],
  providers: [ ThreadListsService ]
})


export class ThreadListsModule { }

Here's the component:

thread-list-tabs.component.ts

import { Component } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Router }   from '@angular/router';
import { ThreadListsService }   from './thread-lists.service';

@Component({
  moduleId: module.id,
  selector: 'thread-list-tabs',
  templateUrl: 'thread-list-tabs.component.html',
  styleUrls: ['thread-list-tabs.component.css']
})


export class ThreadListTabsComponent {

  // Stuff this component does

}

app.module.ts

import { NgModule } from '@angular/core'
import { ThreadListsModule } from './thread-lists/thread-lists.module'
import { OtherModules } from './other.modules'
import { AppComponent } from './app.component'

@NgModule({
  imports: [    
    OtherModules, 
    ThreadListsModule
  ],
  declarations: [ 
    AppComponent
  ],
  providers: [ SomeService ],
  bootstrap: [ AppComponent ]
})

export class AppModule { }

Is there something I'm missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...