ng build --prod 无法确定 X 类的模块!将 ThreadListTabsComponent 添加到 NgModule 以修复它 [英] ng build --prod Cannot determine the module for class X! Add ThreadListTabsComponent to the NgModule to fix it

查看:30
本文介绍了ng build --prod 无法确定 X 类的模块!将 ThreadListTabsComponent 添加到 NgModule 以修复它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建我的 Angular 5 应用程序,但出现错误:

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

无法确定类 ThreadListTabsComponent 中的模块/home/brightwater/Differ/src/app/thread-lists/thread-lists.component.ts!将 ThreadListTabsComponent 添加到 NgModule 以修复它.

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 { }

这是组件:

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 { }

有什么我遗漏的吗?

推荐答案

这看起来像是文件名大小写问题,参见 angular git repo (https://github.com/angular/angular-cli/issues/10732) 上描述的问题

This looks like a filename casing problem, see the issue described on angular git repo (https://github.com/angular/angular-cli/issues/10732)

这篇关于ng build --prod 无法确定 X 类的模块!将 ThreadListTabsComponent 添加到 NgModule 以修复它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆