本文介绍了消费者可以通过 SomeModule 看到这个类 ->SomeComponent,但不是从顶级库入口点导出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 ng update 将我所有的 angular 库升级到 angular 9.0.0,当我尝试构建它们时,出现以下错误.

I upgraded all my angular library to angular 9.0.0 using ng update and when I try to build them I got below error.

错误:

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

有人解决了这个错误吗?

Anyone solved this error?

推荐答案

如果任何组件在 NgModule 中导出并且未包含在您的 public_api.ts 中,则会发生此错误,Angular 9 现在会抛出错误.

This error happens if any component is exported in NgModuleand not included in your public_api.ts, Angular 9 will throw an error now.

这个错误不是在 Angular 8 中出现的,但在升级到 Angular 9 后它开始显示.

This error was not coming in Angular 8 but after upgrading to Angular 9 it started showing.

如果您在 NgModule 中导出了任何 servicemodulecomponent 等,请确保将它们包含在public_api.ts 否则 angular 9 现在会抛出错误.

If you exported any service, module or component, etc in NgModule make sure to include them in public_api.ts or else angular 9 will throw error now.

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

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

这篇关于消费者可以通过 SomeModule 看到这个类 ->SomeComponent,但不是从顶级库入口点导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 03:09