如何将 NPM 连接到 Mac 上的 azure artifacts feed?
How to connect NPM to azure artifacts feed on Mac?
我正在尝试从 Mac 连接到我的私有 npm 源。我从 Connect to feed 菜单生成了凭据,它们看起来像这样:
; begin auth token
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:username=ANYTHING-BUT-EMPTY
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:_password=BASE64-ENCODED-PAT-GOES-HERE
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:email=npm requires email to be set but doesn't use the value
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/:username=ANYTHING-BUT-EMPTY
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/:_password=BASE64-ENCODED-PAT-GOES-HERE
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/:email=npm requires email to be set but doesn't use the value
; end auth token
我把它放在我项目的 .npmrc 文件中,但它不起作用。当我尝试执行 npm install 时,出现此错误:
code E401
npm ERR! Unable to authenticate, need: Bearer authorization_uri=https://login.windows.net/...,
Basic realm="https://pkgsprodsu3weu.app.pkgs.visualstudio.com/", TFS-Federated
我还将这些凭据放在 $HOME 目录中,但也没有解决问题。我究竟做错了什么?它们应该在哪个 .npmrc 文件中?我应该 运行 额外的命令来使用它们吗?
How to connect NPM to azure artifacts feed on Mac?
包含凭据的 .npmrc
文件应设置在 $home
目录中。
查看文档Use npm to store JavaScript packages in Azure DevOps Services or TFS:
On your development machine, you also have an .npmrc file in $home for
Linux or Mac systems, or $env.HOME for Windows systems. This .npmrc
file should contain credentials for all of the registries that you
need to connect to. The npm client will look at your project's .npmrc
file, discover the registry, and fetch matching credentials from
$home/.npmrc or $env.HOME/.npmrc. The next section will discuss
credential acquisition.
由于它仍然不适合您,您可以检查您的 npmrc 令牌是否已过期。在你的 .npmrc 中,我发现你使用的是 BASE64-ENCODED-PAT-GOES-HERE
,看起来你使用的是 PAT,但是在 90 天令牌类型 中。 .npmrc
文件应该像:
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:username=ANYTHING-BUT-EMPTY
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:_password=BASE64-ENCODED-PAT-GOES-HERE
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:email=YOUREMAIL@EXAMPLE.COM
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:always-auth=true
检查Create a token that lasts longer than 90 days。
如果仍然出现401错误,请检查您的PAT是否已过期并转换为Base64String或.
希望对您有所帮助。
在我的例子中,出于某种原因,我需要用双引号和方括号将 base 64 编码的标记括起来以使其工作。
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:_password="[BASE64-ENCODED-PAT-GOES-HERE]"
注意:“[和末尾]”。
添加之后,一切正常。
我是 运行 MacOS Big Sur 11.6
我正在尝试从 Mac 连接到我的私有 npm 源。我从 Connect to feed 菜单生成了凭据,它们看起来像这样:
; begin auth token
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:username=ANYTHING-BUT-EMPTY
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:_password=BASE64-ENCODED-PAT-GOES-HERE
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:email=npm requires email to be set but doesn't use the value
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/:username=ANYTHING-BUT-EMPTY
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/:_password=BASE64-ENCODED-PAT-GOES-HERE
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/:email=npm requires email to be set but doesn't use the value
; end auth token
我把它放在我项目的 .npmrc 文件中,但它不起作用。当我尝试执行 npm install 时,出现此错误:
code E401
npm ERR! Unable to authenticate, need: Bearer authorization_uri=https://login.windows.net/...,
Basic realm="https://pkgsprodsu3weu.app.pkgs.visualstudio.com/", TFS-Federated
我还将这些凭据放在 $HOME 目录中,但也没有解决问题。我究竟做错了什么?它们应该在哪个 .npmrc 文件中?我应该 运行 额外的命令来使用它们吗?
How to connect NPM to azure artifacts feed on Mac?
包含凭据的 .npmrc
文件应设置在 $home
目录中。
查看文档Use npm to store JavaScript packages in Azure DevOps Services or TFS:
On your development machine, you also have an .npmrc file in $home for Linux or Mac systems, or $env.HOME for Windows systems. This .npmrc file should contain credentials for all of the registries that you need to connect to. The npm client will look at your project's .npmrc file, discover the registry, and fetch matching credentials from $home/.npmrc or $env.HOME/.npmrc. The next section will discuss credential acquisition.
由于它仍然不适合您,您可以检查您的 npmrc 令牌是否已过期。在你的 .npmrc 中,我发现你使用的是 BASE64-ENCODED-PAT-GOES-HERE
,看起来你使用的是 PAT,但是在 90 天令牌类型 中。 .npmrc
文件应该像:
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:username=ANYTHING-BUT-EMPTY
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:_password=BASE64-ENCODED-PAT-GOES-HERE
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:email=YOUREMAIL@EXAMPLE.COM
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:always-auth=true
检查Create a token that lasts longer than 90 days。
如果仍然出现401错误,请检查您的PAT是否已过期并转换为Base64String或
希望对您有所帮助。
在我的例子中,出于某种原因,我需要用双引号和方括号将 base 64 编码的标记括起来以使其工作。
//pkgs.dev.azure.com/<yourorganization>/_packaging/<yourfeed>/npm/registry/:_password="[BASE64-ENCODED-PAT-GOES-HERE]"
注意:“[和末尾]”。
添加之后,一切正常。
我是 运行 MacOS Big Sur 11.6