首页 > 解决方案 > 此类通过 SomeModule -> SomeComponent 对消费者可见,但不会从顶级库入口点导出

问题描述

我将我所有的角度库都升级为angular 9.0.0使用ng update,当我尝试构建它们时,我得到了以下错误。

错误:

不支持的私有类 SomeComponent。此类通过 SomeModule -> SomeComponent 对消费者可见,但不会从顶级库入口点导出。

有人解决了这个错误吗?

标签: angularangular-libraryangular9

解决方案


如果任何组件被导出NgModule但未包含在您的 中public_api.ts,则会发生此错误,Angular 9现在将引发错误。

这个错误没有出现,Angular 8但在升级到Angular 9它之后开始显示。

如果您导出了任何service,modulecomponent, 等,请NgModule确保将它们包括在内,public_api.ts否则angular 9现在会抛出错误。

修复:将您的组件添加到public_api.ts

export * from './lib/components/some-me/some-me.component';

推荐阅读