使用双重身份验证访问 npm

使用安全密钥流从命令行登录

  1. 在命令行上,键入 npm login 命令。

  2. 出现提示时,提供您的用户名、密码和电子邮件地址。

    user@host:~$ npm login
    npm notice Log in on https://registry.npmjs.org/
    Username: mona
    Password:
    Email: (this IS public) mona@github.com
    npm notice Open https://www.npmjs.com/login/913c3ab1-89a0-44bd-be8d-d946e2e906f0 to use your security key for authentication or enter OTP from your authenticator app
    
  3. 如果您已配置安全密钥,请打开命令行中显示的提供的 URL。或者,如果您已配置移动验证器,请跳至步骤 6。

  4. 单击使用安全密钥并按照浏览器特定的步骤进行身份验证。

  5. 复制生成的令牌

  6. EoORjqMvgtDszw6xXHVCRe9Oha4mn700rr4j0tnbEVLrPNttVTwQItrG3UhDz68p

    HH1HSfRnU0vNDuL/upfftIQh2ytNmnbBJyfaiCpe0SI=

使用 --auth-type=web 从命令行登录

/yw6NN9GrrUvwPnEKrJxfzjt4BAyzpgLbpS7QM0gD5Xf9ttJsok69Ppi2RPWwwyiox4jJ50DQGNMV736fhNzRWa2/jDlfcLnRkmb6c3oGLqzUqGm532iTFeCFmE1vGunopL0PX0gDRpVBMUqCpnLE7z/CTbznenAo+1oXvvYWQY=

使用现有的浏览器会话

  1. 75lTrFl14dFpONcFuVWK33fzWQvihiEejGq7QHgV2ePZ7jpXzOlItJWCuUUl57awo3RkiT3LPGj4m5g2kjyi6NixSMqwgCC8dhqNAGP77/AvqyTJsWhMRiFwxqGjHY5cpt85+GOLGYbr0vqMMxYiA8ZNa4uxH8MDaPa8DW1taiA=

  2. caGQE52Bc4IQJ2JKvfbFHaOSayQyDNPXLQC9GC7+QjLtnF/ZzuO6rqou5TJdrEvshL2KpWNLMeM40F7gSxswCdi6ecFX74TJbOIjPEJKvJmz2GskDpYdt9OCcnVGkbp0ZuYK01Qm1dSah3YpNgaYDA==

user@host:~$ npm login
npm notice Log in on https://registry.npmjs.org/
Authenticate your account at:
https://www.npmjs.com/login?next=/login/cli/b1a2f96a-ce09-4463-954c-c99f6773b922
Press ENTER to open in the browser...
  1. O4Ocq5EEzFSo/I308KY+PNCmcHK7EhPqIxhrPUvER6/xQE4JNgpE1m8HiJnROnQEe/52oaqSnQuzv3bUyJmxJdqKWxj2QU/T2Sqjhu9muuI=

    BotpvuJgiYw1Jyl7ofx8pqbaFLPWAtsjMlSAmDgsrG1ofyx19uf+WodWq6FeRLaQ07IAgCETCn+jK3ggdPPVPZlbkPOz5770mVkUCVDI5E0=

没有现有的浏览器会话

  1. 75lTrFl14dFpONcFuVWK33fzWQvihiEejGq7QHgV2ePZ7jpXzOlItJWCuUUl57awo3RkiT3LPGj4m5g2kjyi6NixSMqwgCC8dhqNAGP77/AvqyTJsWhMRiFwxqGjHY5cpt85+GOLGYbr0vqMMxYiA8ZNa4uxH8MDaPa8DW1taiA=

  2. caGQE52Bc4IQJ2JKvfbFHaOSayQyDNPXLQC9GC7+QjLtnF/ZzuO6rqou5TJdrEvshL2KpWNLMeM40F7gSxswCdi6ecFX74TJbOIjPEJKvJmz2GskDpYdt9OCcnVGkbp0ZuYK01Qm1dSah3YpNgaYDA==

user@host:~$ npm login
npm notice Log in on https://registry.npmjs.org/
Authenticate your account at:
https://www.npmjs.com/login?next=/login/cli/b1a2f96a-ce09-4463-954c-c99f6773b922
Press ENTER to open in the browser...
  1. 6dm2YackLMaq43qIDrkANCqZvfGzwpZJMU7IdlolC2kY3p38EzScYYvc+OJ85mev9xbgOIKfacjMAKJnrjItAsdcRRflr+I0XxnkeITQDBDIBnYtR5OjG1Urr4iuGPOU

  2. O4Ocq5EEzFSo/I308KY+PNCmcHK7EhPqIxhrPUvER6/xQE4JNgpE1m8HiJnROnQEe/52oaqSnQuzv3bUyJmxJdqKWxj2QU/T2Sqjhu9muuI=

    BotpvuJgiYw1Jyl7ofx8pqbaFLPWAtsjMlSAmDgsrG1ofyx19uf+WodWq6FeRLaQ07IAgCETCn+jK3ggdPPVPZlbkPOz5770mVkUCVDI5E0=