angular构建npm包报错:It is not recommended to publish Ivy libraries to NPM repositories.

在使用angular自定义组件库,构建npm包时报错:It is not recommended to publish Ivy libraries to NPM repositories.

ERROR: projects/ngx-zorro/src/lib/alert/alert.component.ts:8:14 - error NG3001: Unsupported private class AlertComponent. This class is visible to consumers via NgxZorroModule -> AlertComponent, but is not exported from the top-level library entrypoint.

Building Angular Package
******************************************************************************
It is not recommended to publish Ivy libraries to NPM repositories.
Read more here: https://v9.angular.io/guide/ivy#maintaining-library-compatibility
******************************************************************************

------------------------------------------------------------------------------
Building entry point 'ngx-zorro'
------------------------------------------------------------------------------
Compiling TypeScript sources through ngc
ERROR: projects/ngx-zorro/src/lib/alert/alert.component.ts:8:14 - error NG3001: Unsupported private class AlertComponent. This class is visible to consumers via NgxZorroModule -> AlertComponent, but is not exported from the top-level library entrypoint.

8 export class AlertComponent implements OnInit {
               ~~~~~~~~~~~~~~~

An unhandled exception occurred: projects/ngx-zorro/src/lib/alert/alert.component.ts:8:14 - error NG3001: Unsupported private class AlertComponent. This class is visible to consumers via NgxZorroModule -> AlertComponent, but is not exported from the top-level library entrypoint.

8 export class AlertComponent implements OnInit {
               ~~~~~~~~~~~~~~~

解决:
由于ng9之后默认使用ivy引擎。官方并不建议把 Ivy 格式的库发布到 NPM 仓库。
因此在发布到 NPM 之前,我们使用–prod标志构建它,此标志会使用老的编译器和运行时,也就是视图引擎(View Engine),以代替 Ivy。

ng build ngx-zorro --prod
在这里插入图片描述
另外,打包前修改package.json中的项目信息,每次更新npm包需修改version,版本相同提交不上去,可以手动修改,也可命令修改,如下:npm version prepatch

更多操作:

# 版本号从 1.2.3 变成 1.2.4-0,就是 1.2.4 版本的第一个预发布版本。
npm version prepatch

# 版本号从 1.2.4-0 变成 1.3.0-0,就是 1.3.0 版本的第一个预发布版本。
npm version preminor

# 版本号从 1.2.3 变成 2.0.0-0,就是 2.0.0 版本的第一个预发布版本。
npm version premajor

# 版本号从 2.0.0-0 变成 2.0.0-1,就是使预发布版本号加一。
npm version prerelease
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值