🌐 Sign in from the command line using security-key flow
在命令行中,输入 npm login 命令。
出现提示时,提供你的用户名、密码和电子邮件地址。
user@host:~$ npm loginnpm notice Log in on https://registry.npmjs.org/Username: monaPassword:Email: (this IS public) mona@github.comnpm 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
如果你已经配置了安全密钥,请打开命令行中显示的提供的 URL。或者,如果你已经配置了移动身份验证器,请跳到第 6 步。
点击使用安全密钥,然后按照浏览器的具体步骤进行身份验证。
复制生成的令牌
在 CLI 提示符中输入一次性密码。
输入一次性密码:--auth-type=web 从命令行登录🌐 Sign in from the command line using --auth-type=web
npm 8.14.0 及更高版本支持通过浏览器进行登录流程。在 npm 9 中,这将成为 npm 公共注册表的默认行为。
🌐 npm 8.14.0 and higher support login flow through the browsers. This will become the default behavior for the npm public registry in npm 9.
🌐 With an existing browser session
在命令行中,输入 npm login --auth-type=web 命令。
当出现提示时,按“回车”键以打开浏览器开始登录流程,或点击命令行中提供的 URL。
user@host:~$ npm loginnpm notice Log in on https://registry.npmjs.org/Authenticate your account at:https://www.npmjs.com/login?next=/login/cli/b1a2f96a-ce09-4463-954c-c99f6773b922Press ENTER to open in the browser...
点击使用安全密钥,然后按照浏览器的具体步骤进行身份验证。
注意:如果你已配置使用 TOTP,你将会看到 TOTP 提示
🌐 Without an existing browser session
在命令行中,输入 npm login --auth-type=web 命令。
当出现提示时,按“回车”键以打开浏览器开始登录流程,或点击命令行中提供的 URL。
user@host:~$ npm loginnpm notice Log in on https://registry.npmjs.org/Authenticate your account at:https://www.npmjs.com/login?next=/login/cli/b1a2f96a-ce09-4463-954c-c99f6773b922Press ENTER to open in the browser...
点击使用安全密钥,然后按照浏览器的具体步骤进行身份验证。
注意:如果你已配置使用 TOTP,你将会看到 TOTP 提示