博客 / 詳情

返回

npm包發佈403錯誤

錯誤現象

執行 npm publish 命令發佈包時,遇到以下錯誤

npm error 403 403 Forbidden - PUT `https://registry.npmjs.org/xxxx`  - Two-factor authentication or granular access token with bypass 2fa enabled is required to publish packages.

根本原因

發佈npm包時,必須使用以下驗證方式:

  • 雙因素認證(2FA) :已啓用2FA的賬號,發佈時需輸入動態驗證碼

解決辦法

  1. 登錄 npm官網http://www.npmjs.com/
  2. 進入 Account Settings → Security
  3. 啓用 Two-Factor Authentication
  4. 完成設置
  5. 執行發佈命令: npm publish
  6. 輸入Authenticator應用生成的驗證碼
  7. 發佈成功
user avatar
0 位用戶收藏了這個故事!

發佈 評論

Some HTML is okay.