[英]NgxNotification Component fails in production build. Angular 7
我在App Module中使用了NgxNotificationComponent。 这在ng服务中效果很好。 但是当我尝试使用ng build --prod构建应用程序时,它会抛出错误。
ERROR in : Type NgxNotificationComponent in /Development/web-
angular/node_modules/ngx-notification/ngx-notification.d.ts is part of
the declarations of 2 modules: AppModule in /Development/web-
angular/src/app/app.module.ts and NgxNotificationModule in
/Development/web-angular/node_modules/ngx-notification/ngx-
notification.d.ts! Please consider moving NgxNotificationComponent in
/Development/web-angular/node_modules/ngx-notification/ngx-
notification.d.ts to a higher module that imports AppModule in
/Development/web-angular/src/app/app.module.ts and
NgxNotificationModule in /Development/web-angular/node_modules/ngx-
notification/ngx-notification.d.ts. You can also create a new NgModule
that exports and includes NgxNotificationComponent in /Development/web-
angular/node_modules/ngx-notification/ngx-notification.d.ts then import
that NgModule in AppModule in /Development/web-
angular/src/app/app.module.ts and NgxNotificationModule in
/Development/web-angular/node_modules/ngx-notification/ngx-
notification.d.ts
我是否必须更改节点模块本身或是否有任何解决方法。
版本如下
"ngx-notification": "^1.0.5",
开发依赖
"@angular-devkit/build-angular": "~0.11.0",
"@angular/cli": "~7.1.4",
在app.module.ts中导入的不是NgxNotificationComponent到声明,而是导入的NgxNotificationModule 。 该文档不是很正确。
它可以在生产中使用:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgxNotificationModule} from 'ngx-notification';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NgxNotificationModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.