ng build --prod Cannot determine the module for class X! Add ThreadListTabsComponent to the NgModule to fix it
11,868
This looks like a filename casing problem, see the issue described on angular git repo (https://github.com/angular/angular-cli/issues/10732)
Related videos on Youtube
Comments
-
J. Adam Connor almost 2 years
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?
-
Daniel W Strimpel almost 6 yearsThat error is complaining about a class in the
thread-lists.component.ts
file but you have thethread-list-tabs.component.ts
file shown above. Is it possible that you are looking in the wrong file for the problem class? -
J. Adam Connor almost 6 yearsGood eye! thread-lists and thread-list-tabs a duplicate components. This fixed the issue. You're welcome to post the answer if you like and I'll accept--though I wonder how helpful such answers are, as they're so specific and related to my own blindness... Thank you, though.
-