共计 1298 个字符,预计需要花费 4 分钟才能阅读完成。
我明天照着 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-2…
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… – 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 的原创文章,尽在:” 汪子熙 ”: