我将我所有的角度库都升级为angular 9.0.0
使用ng update
,当我尝试构建它们时,我得到了以下错误。
错误:
不支持的私有类 SomeComponent。此类通过 SomeModule -> SomeComponent 对消费者可见,但不会从顶级库入口点导出。
有人解决了这个错误吗?
我将我所有的角度库都升级为angular 9.0.0
使用ng update
,当我尝试构建它们时,我得到了以下错误。
错误:
不支持的私有类 SomeComponent。此类通过 SomeModule -> SomeComponent 对消费者可见,但不会从顶级库入口点导出。
有人解决了这个错误吗?
如果任何组件被导出NgModule
但未包含在您的 中public_api.ts
,则会发生此错误,Angular 9
现在将引发错误。
这个错误没有出现,Angular 8
但在升级到Angular 9
它之后开始显示。
如果您导出了任何service
,module
或component
, 等,请NgModule
确保将它们包括在内,public_api.ts
否则angular 9
现在会抛出错误。
修复:将您的组件添加到public_api.ts
export * from './lib/components/some-me/some-me.component';
我今天在同样的问题上苦苦挣扎。
我的先决条件:
使固定:
export * from './just/a/relative/path/to/the/directive/{{myDirectiveFile}}';
这个错误发生在我身上,因为我使用default
关键字导出我的组件:
@Component({
selector: 'lib-form',
templateUrl: './form.component.html',
styleUrls: ['./form.component.scss'],
})
export default class FormComponent implements OnInit {
// ...
}
我的 Linter 建议使用这个关键字,并允许将导入写为import FormComponent from './form.component';
而不是import { FormComponent } from './form.component';
然而,这似乎并不奏效public-api.ts
。我的解决方案是删除default
关键字并更改所有导入。