我有一个角度为4的应用程序,在ng server
的本地计算机上正常运行但是当我尝试使用ng build -- prod
构建生产应用程序时,我遇到错误,没有出错生产运行。错误是: -
WARNING in Invalid background value at 12864:14. Ignoring.
完整详细错误
ERROR in : Type ModalsComponent in E:/Projects/Rudram Admin/Code/app/src/app/pages/ui-features/modals/modals.component.ts is part of the declarations
of 2 modules: JobListModdule in E:/Projects/Rudram Admin/Code/app/src/app/pages/joblist/joblist.module.ts and UiFeaturesModule in E:/Projects
/Rudram Admin/Code/app/src/app/pages/ui-features/ui-features.module.ts! Please consider moving ModalsComponent in E:/Projects/Rudram Admin/Code
/app/src/app/pages/ui-features/modals/modals.component.ts to a higher module that imports JobListModdule in E:/Projects/Rudram Admin/Code/app/src
/app/pages/joblist/joblist.module.ts and UiFeaturesModule in E:/Projects/Rudram Admin/Code/app/src/app/pages/ui-features/ui-features.module.ts. You
can also create a new NgModule that exports and includes ModalsComponent in E:/Projects/Rudram Admin/Code/app/src/app/pages/ui-features/modals
/modals.component.ts then import that NgModule in JobListModdule in E:/Projects/Rudram Admin/Code/app/src/app/pages/joblist/joblist.module.ts and
UiFeaturesModule in E:/Projects/Rudram Admin/Code/app/src/app/pages/ui-features/ui-features.module.ts.
注意 - > 如果我只是简单地使用ng biuld
,那么它不会产生任何错误,但在这种情况下,应用程序会加载大量时间加载大约5到6分钟。
答案 0 :(得分:0)
因为错误说ModalsComponent
(modals.component.ts
)在两个模块modals.component.ts is part of the declarations
of 2 modules: JobListModdule ... and UiFeaturesModule
中声明。
因此,如错误所示,创建共享模块并在那里导入ModalsComponent会更好
You can also create a new NgModule that exports and includes ModalsComponent in E:/Projects/Rudram Admin/Code/app/src/app/pages/ui-features/modals
/modals.component.ts then import that NgModule in JobListModdule in E:/Projects/Rudram Admin/Code/app/src/app/pages/joblist/joblist.module.ts and
UiFeaturesModule in E:/Projects/Rudram Admin/Code/app/src/app/pages/ui-features/ui-features.module.ts.
直接来自文档https://angular.io/guide/sharing-ngmodules