📖 閱讀本文大概須要 6 分鐘。vue
有兩種方案:git
(推薦)一、直接上 npmjs.com 官網搜索github
二、也能夠用一些工具庫查找,雖然有點多此一舉,但某些場景仍是適用的。好比動態發佈包。npm
2、npm 官網註冊帳號(略)json
$ npm init -y
重點關注和修改如下三項:bash
{
"name": "chuanghui-vue-portal", "version": "0.0.1", "main": "src/components/chuanghui-portal.vue", "description": "ChuangHui Vue Components", "author": "lizhaohong <928532756@qq.com>" }
先添加 npm 帳號app
$ npm adduser
Username: ...
Password: ...
Email: (this IS public) 928532756@qq.com
Logged in as cylee on https://registry.npmjs.org/.
正式發佈,就一句話。工具
$ npm publish
正常的話,在 npm 我的 package 頁面中能夠看到上傳的包:ui
只須要把你 package.json
的 version
版本號改變,如 0.0.1 -> 0.0.2,再執行 $ npm publish
便可。this
若是你和我同樣有強迫症,僅僅是修復一個 bug 就要把版本號從 0.0.1 升級到 0.02。
內心確定很糾結,更多的多是選擇刪掉包從新上傳。
網上介紹刪除發佈包的方法倒也簡單。執行如下便可:
$ npm unpublish --force
但你可能出現 ERR:2FA
之類的錯誤信息?那你可能要先進行一大堆設置了,看下去吧。
簡單歸納:
具體設置步驟:官方教程
一、到 App 商店搜索而且下載 Microsoft Authenticator App.
二、進入 npm 後臺,找到如圖所示:
三、選擇 [Authorization and Publishing] - [submit]
四、打開 Authenticator App,選擇 「添加帳戶」 - 「其餘帳戶(Google、Facebook 等)」
五、掃描 步驟3
後的二維碼。
六、體驗 One-time Password。如圖所示
七、使用 One-time Password 刪除發佈包。須要加上 --otp <One-time Password>
$ npm unpublish chuanghui-portal --force --otp 863613
開通了 2FA 之後,你的帳號發佈包$ npm publish
都是須要使用 One-Time Password的。
$ npm publish --otp 863613