【问题标题】:Cannot determine the module for class - ng build --prod无法确定类的模块 - ng build --prod
【发布时间】:2019-05-20 18:49:27
【问题描述】:

我在执行时遇到以下错误

ng 构建 --prod

但是

构建

工作正常。


我在堆栈溢出中找到了许多相同的解决方案,但没有一个有效

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

Angular `ng build --prod` issue


见下面的错误:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS D:\IT_INF_Hol_INFstructureSuite_Cit\Projects\CitH_UI> ng build --prod

Date: 2018-12-20T08:56:40.759Z
Hash: 89b0db73219a42cd9dc4
Time: 14183ms
chunk {0} runtime.ec2944dd8b20ec099bf3.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.9868d9b237c3a48c54da.js (main) 128 bytes [initial] [rendered]
chunk {2} polyfills.85f47f0bf59079cbc23a.js (polyfills) 130 bytes [initial] [rendered]
chunk {3} styles.898f3785f5d9ae4bd624.css (styles) 387 kB [initial] [rendered]
chunk {scripts} scripts.aa85510fa2abfcc665b6.js (scripts) 326 kB  [rendered]

ERROR in : Cannot determine the module for class ModelComponet in D:/IT_INF_Hol_INFstructureSuite_Cit/Projects/CitH_UI/src/app/Views/model/model-component.ts! Add ModelComponet to the NgModule to fix it.
Cannot determine the module for class FilterPipe in D:/IT_INF_Hol_INFstructureSuite_Cit/Projects/CitH_UI/src/app/Shared/Directives/DataTable/DataFilter.ts! Add FilterPipe to the NgModule to fix it.
Cannot determine the module for class HolCarouselComponent in D:/IT_INF_Hol_INFstructureSuite_Cit/Projects/CitH_UI/src/app/Views/Hol/carousel/Hol-carousel.component.ts! Add HolCarouselComponent to the NgModule to
fix it.
Cannot determine the module for class HolSolutions1Component in D:/IT_INF_Hol_INFstructureSuite_Cit/Projects/CitH_UI/src/app/Views/Hol/solutions/Hol-solution1.component.ts! Add HolSolutions1Component to the NgModule to fix it.
Cannot determine the module for class LogOnComponent in D:/IT_INF_Hol_INFstructureSuite_Cit/Projects/CitH_UI/src/app/Views/log-on/log-on.component.ts! Add LogOnComponent to the NgModule to fix it.
Cannot determine the module for class ManageConfigsCopy in D:/IT_INF_Hol_INFstructureSuite_Cit/Projects/CitH_UI/src/app/Views/manage-configs/manage-configs.component - Copy.ts! Add ManageConfigsCopy to the NgModule to fix it.Cannot determine the module for class TestComponent in D:/IT_INF_Hol_INFstructureSuite_Cit/Projects/CitH_UI/src/app/Views/test-jp/test.component.ts! Add TestComponent to the NgModule to fix it.

模型组件.ts

import { Component, OnInit } from '@angular/core';
import {ModalModule} from "ngx-modal";
import { NgModule }      from '@angular/core'

@Component({
  selector: 'ngx-model',
  templateUrl: './model-component.html'
})
export class ModelComponet implements OnInit {

 // lstMenuItems:MenuEntities[];

 // constructor(private Menu_Service:MenuService,private clsmenu:MenuEntities) { }
  constructor() { }
  ngOnInit() {
   //this.loadMenu();
  }
}

【问题讨论】:

  • 确保在 app.module.ts 文件中注册了这些组件

标签: javascript jquery angular typescript


【解决方案1】:

您能否验证 ModelComponet 是 a) 在一个模块中和 b) 该模块最终被导入到您的 AppModule 中吗?

下一步是将其分解为更简单的示例并提供更多代码(包括加载组件的 HTML、appmodule、featuremodule、component.ts)。

【讨论】:

  • ModelComponet 从未在 app.module.ts 中使用
  • 是的,请仔细阅读。您需要验证 ModelComponet 是否在某个模块中,并且该模块最终在应用模块中。
  • 只用过两个地方
  • 澄清一下,ModelComponent 应该是您的 AppModule 声明的一部分。如果它不在那个数组中,它就没有被使用。
  • 恐怕你不明白我的意思。验证是否在您的 AppModule 或另一个模块中声明了 ModelComponent,然后将其导入您的应用程序模块。如果您需要帮助,请仔细阅读。
猜你喜欢
  • 2018-10-08
  • 1970-01-01
  • 2018-04-03
  • 2018-03-17
  • 2021-10-05
  • 1970-01-01
  • 2018-11-25
  • 1970-01-01
  • 2017-07-04
相关资源
最近更新 更多