认证相关配置

中英双语

设置 _auth_authTokenusername_password 都必须限定在特定注册表范围内。这可确保 npm 永远不会将凭据发送到错误的主机。

为了限定这些值的范围,它们必须以 URI 片段为前缀。如果凭证用于对单个主机上的注册表的任何请求,则范围可能类似于 //registry.npmjs.org/:。如果必须将其范围限定为主机上的特定路径,则还可以提供该路径,例如 //my-custom-registry.org/unique/path:

; bad config
_authToken=MYTOKEN

; good config
@myorg:registry=https://somewhere-else.com/myorg
@another:registry=https://somewhere-else.com/another
//registry.npmjs.org/:_authToken=MYTOKEN
; would apply to both @myorg and @another
; //somewhere-else.com/:_authToken=MYTOKEN
; would apply only to @myorg
//somewhere-else.com/myorg/:_authToken=MYTOKEN1
; would apply only to @another
//somewhere-else.com/another/:_authToken=MYTOKEN2