0背景
npm 对于已有的包更新和新的包发布,认为原先的 npm 登录密码安全性太差,增加了 2FA 校验。npm 给出的官方文档地址为:docs.npmjs.com/configuring…
1如何开启 2FA
- 登录到 npm 官网(地址 www.npmjs.com),输入账号密码;
- 手机应用商店下载 Authenticator App;
- npm 中选择 QE 登录,用下载的 Authenticator App 扫码关联,这样 Authenticator App 可关联到你的 npm 账户;
- npm 源切换到 npm 官方路径;
- npm login 输入账号密码;
- npm notice "Please use the one-time password (OTP) from your authenticator application" 提示时输入一次性校验密码;
- npm publish 发布时候需要增加上动态密码:
npm publish --opt=六位动态密码。
⚠️ 提示:开启 2FA 校验后,发布和更新均需要一次性密码。当然,你也可以在 account 中关闭掉一次性密码登录。