前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >npm publish 发布一个 Angular 库的时候报错以及解决方法

npm publish 发布一个 Angular 库的时候报错以及解决方法

作者头像
Jerry Wang
发布2021-10-21 11:33:31
1.6K0
发布2021-10-21 11:33:31
举报

我今天照着 npm 文件,打算把自己开发的 npm 库发布到公网上:

npm login 之后,使用命名行 npm config set registry=http://registry.npmjs.org, 遇到如下错误:

npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/ npm ERR! code E426 npm ERR! 426 Upgrade Required - PUT http://registry.npmjs.org/my-lib

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\I042416\AppData\Roaming\npm-cache_logs\2021-10-17T02_40_15_408Z-debug.log

大意是,从2021年10月4日开始,所有前往 npm registry 的连接,都需要使用 TLS 1.2 了.

因此,我把命名行改成使用 https,旧的错误消息就消失了:

npm config set registry=http://registry.npmjs.org

然而我又遇到了新的错误消息:you do not have permission to publish “my-lib”. Are you logged in as the correct user?

npm ERR! code E403 npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/my-lib - You do not have permission to publish “my-lib”. Are you logged in as the correct user? npm ERR! 403 In most cases, you or one of your dependencies are requesting npm ERR! 403 a package version that is forbidden by your security policy.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\I042416\AppData\Roaming\npm-cache_logs\2021-10-17T02_44_36_666Z-debug.log

这个错误的原因是,我在 package.json 里使用的库名称为 my-lib, 这是我从 npm 教程里照抄的,已经有人将同名的库上传到 npm 仓库去了,因此我没有权限上传一个同名的库。

将 package.json 里的 name 字段修改即可:

之后就能够成功上传库了:

更多Jerry的原创文章,尽在:“汪子熙”:

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2021-10-17 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
SSL 证书
腾讯云 SSL 证书(SSL Certificates)为您提供 SSL 证书的申请、管理、部署等服务,为您提供一站式 HTTPS 解决方案。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档