目錄
npm-login
登入登錄檔使用者帳戶
選擇 CLI 版本
目錄
概要
npm login
注意:此指令不了解工作區。
描述
驗證指定登錄檔中的使用者,並將憑證儲存到 .npmrc
檔案。如果未指定登錄檔,將使用預設登錄檔(請參閱 config
)。
當使用 legacy
作為 auth-type
時,會從提示中讀取使用者名稱和密碼。
若要重設密碼,請前往 https://www.npmjs.com/forgot
若要變更您的電子郵件地址,請前往 https://www.npmjs.com/email-edit
您可以在同一使用者帳戶中多次使用此指令,以在新機器上授權。在新的機器上驗證時,使用者名稱、密碼和電子郵件地址都必須與您現有的記錄相符。
組態
登錄檔
- 預設值:"https://registry.npmjs.org/"
- 類型:URL
npm 登錄的基礎 URL。
範圍
- 預設值:目前專案的範圍(若有),或 ""
- 類型:字串
將作業與範圍化登錄的範圍關聯。
在登入或登出私人登錄時很有用
# log in, linking the scope to the custom registrynpm login --scope=@mycorp --registry=https://registry.mycorp.com# log out, removing the link and the auth tokennpm logout --scope=@mycorp
這將導致 @mycorp
根據模式 @mycorp/package
指定的套件未來安裝時,對應到登錄。
這也會導致 npm init
建立範圍化套件。
# accept all defaults, and create a package named "@foo/whatever",# instead of just named "whatever"npm init --scope=@foo --yes
驗證類型
- 預設值:"web"
- 類型:"legacy" 或 "web"
與 login
搭配使用的驗證策略。請注意,如果給定 otp
設定,此值將永遠設為 legacy
。