Angular 2 Aot Error: 'ToastsManager' is not exported

妖精的绣舞 提交于 2020-01-05 03:54:04

问题


While performing AOT I'm facing issue with ng2-toastr which I'm using

ToastsManager' is not exported by 'node_modules\ng2-toastr\src\toast-manager.js


 'ToastModule' is not exported by 'node_modules\ng2-toastr\src\toast.module.js'.



'ToastOptions' is not exported by 'node_modules\ng2-toastr\src\toast-options.js'.

Any idea on how to resolve this? I checked all those mentioned files, they have export declare keywords with them, even checked with this site

https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module


回答1:


You can solve this by making a change to the rollup config js file. You need to make 2 changes to the commonjs plugin config.

Here is mine after the change. Note you need to add both the extra include and the namedExports.

      plugins: [
          nodeResolve({jsnext: true, module: true}),
          commonjs({
             include: [ 
                'node_modules/rxjs/**',
                'node_modules/ng2-toastr/**'
             ],
             namedExports : { 
                'node_modules/ng2-toastr/ng2-toastr.js': [ 'ToastModule', 'ToastsManager' ] 
             }
          }),
          uglify()
       ]



回答2:


Are you using any third party libraries? If so take care of the following

  • The third party library has to be AoT compiled itself.
  • The third party library has to export the JS source, the d.ts files and all generated metadata.json files.


来源:https://stackoverflow.com/questions/41114379/angular-2-aot-error-toastsmanager-is-not-exported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!