npm 配置文件 profile

2021-10-29 10:50 更新

更改注冊表配置文件上的設(shè)置

概要

  1. npm profile get [--json|--parseable] [<property>]
  2. npm profile set [--json|--parseable] <property> <value>
  3. npm profile set password
  4. npm profile enable-2fa [auth-and-writes|auth-only]
  5. npm profile disable-2fa

描述

在注冊表中更改您的配置文件信息。如果您使用的是非 npmjs 注冊表,則此選項不可用。

npm profile get [<property>]:顯示您的配置文件的所有屬性,或一個或多個特定屬性。看起來像:

  1. +-----------------+---------------------------+
  2. | name | example |
  3. +-----------------+---------------------------+
  4. | email | me@example.com (verified) |
  5. +-----------------+---------------------------+
  6. | two factor auth | auth-and-writes |
  7. +-----------------+---------------------------+
  8. | fullname | Example User |
  9. +-----------------+---------------------------+
  10. | homepage | |
  11. +-----------------+---------------------------+
  12. | freenode | |
  13. +-----------------+---------------------------+
  14. | twitter | |
  15. +-----------------+---------------------------+
  16. | github | |
  17. +-----------------+---------------------------+
  18. | created | 2015-02-26T01:38:35.892Z |
  19. +-----------------+---------------------------+
  20. | updated | 2017-10-02T21:29:45.922Z |
  21. +-----------------+---------------------------+
  • npm profile set <property> <value>:設(shè)置配置文件屬性的值。你可以通過這種方式設(shè)置以下屬性:emailfullname、homepagefreenodetwitter、github

  • npm profile set password: 更改你的密碼。這是交互式的,系統(tǒng)會提示你輸入當前密碼和新密碼。如果你啟用了雙因素身份驗證,系統(tǒng)還會提示你輸入 OTP。

  • npm profile enable-2fa [auth-and-writes|auth-only]:啟用兩因素身份驗證。默認為auth-and-writes模式。模式是:

    • auth-only:登錄或更改帳戶身份驗證時需要 OTP。網(wǎng)站和命令行都需要 OTP。
    • auth-and-writes:始終需要一個 OTP?auth-only,并且在發(fā)布模塊、設(shè)置latestdist-tag 或通過npm access和更改訪問時也需要一個npm owner。

  • npm profile disable-2fa:禁用兩因素身份驗證。

細節(jié)

所有npm profile子命令都接受--json并將--parseable根據(jù)這些來定制它們的輸出。其中一些命令在非 npmjs.com 注冊表上可能不可用。

配置

registry 注冊表

  • 默認值:https://registry.npmjs.org/
  • 類型:Url

npm 注冊表的基本 URL。

json

  • 默認值:false
  • 類型:Boolean

是否輸出JSON數(shù)據(jù),而不是正常輸出。

npm pkg set它允許在將設(shè)置值保存到您的package.json.并非所有 npm 命令都支持。

parseable 可解析

  • 默認值:false
  • 類型:Boolean

從寫入標準輸出的命令輸出可解析的結(jié)果。對于?npm search,這將是制表符分隔的表格格式。

otp

  • 默認值:null
  • 類型:nullString

這是來自兩因素身份驗證器的一次性密碼。使用npm access.

如果未設(shè)置,并且注冊表響應(yīng)失敗并質(zhì)詢一次性密碼,npm 將在命令行上提示輸入密碼。

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號