NgxNotification组件在生产版本中失败。角度7

时间:2019-03-19 03:25:03

标签: angular angular7 dev-to-production

我在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",

Dev依赖项

"@angular-devkit/build-angular": "~0.11.0",
"@angular/cli": "~7.1.4",

1 个答案:

答案 0 :(得分:0)

将app.module.ts导入声明时不是 NgxNotificationComponent ,而是导入 NgxNotificationModule 。该文档不太正确。
它可用于生产环境:

prop