本文介绍了npm发布天蓝色文物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将作用域软件包发布到私有的Azureure Devops工件提要.我按照说明在此处.我有一个具有以下条目的项目.npmrc:

I'm trying to publish a scoped package to a private azure devops artifact feed. I followed the instructions here. I have a project .npmrc with the following entries:

@my-scope:registry=https://pkgs.dev.azure.com/my-org/_packaging/my-feed/npm/registry/
@my-scope:always-auth=true

在我的全局用户.npmrc中,我具有以下条目:

In my global user .npmrc I have the following entries:

prefix=/usr/local
strict-ssl=false
unsafe-perm=true
//registry.npmjs.org/:_authToken="my-real-token"
//pkgs.dev.azure.com/my-org/_packaging/my-feed/npm/registry/:username=${NPM_USERNAME}
//pkgs.dev.azure.com/my-org/_packaging/my-feed/npm registry/:_password="my-real-base64-token"
//pkgs.dev.azure.com/my-org/_packaging/my-feed/npm/registry/:email=${NPM_EMAIL}
//pkgs.dev.azure.com/my-org/_packaging/my-feed/npm/registry/:always-auth=true
@my-scope:registry=https://pkgs.dev.azure.com/my-org/_packaging/my-feed/npm/registry/
//pkgs.dev.azure.com/my-org/_packaging/my-feed/npm registry/:_authToken="my-real-base64-token"
cafile=${NPM_CERT_LOCATION}

当我尝试:npm publish时,出现以下错误:

When I try: npm publish I get the following error:

Unable to authenticate, need: Bearer authorization_uri=https://login.windows.net/some-guid, Basic realm="https://pkgsprodcus1.pkgs.visualstudio.com/", TFS-Federated

根据以前的帖子,我看到我可能需要进行npm登录.执行npm登录会给我这个错误:

Based on previous posts I see that I might need to do npm login. Executing npm login gives me this error:

npm verb node v6.9.2
npm verb npm  v6.8.0
npm ERR! code E400
npm ERR! 400 Bad Request - PUT https://pkgs.dev.azure.com/my-org/_packaging/my-feed/npm/registry/-/user/org.couchdb.user:my-username

我看过了和相关.但是,它们都不起作用.我尝试过:curl和curl -u这给了我以下错误:

I looked at this and this which seemed to be related. However, neither of them worked.I've tried: curl and curl -u which gave me the following error:

{"$id":"1","innerException":null,"message":"TF400813: Resource not available for anonymous access. Client authentication required.","typeName":"Microsoft.TeamFoundation.Framework.Server.UnauthorizedRequestException, Microsoft.TeamFoundation.Framework.Server","typeKey":"UnauthorizedRequestException","errorCode":0,"eventId":3000}%

我也尝试使用代理和证书.但是,结果相同.

I'v also tried with a proxy and a cert. However, with the same results.

推荐答案

这有点旧,不确定是否仍然卡住,但对于Windows,可以使用以下npm软件包:https://www.npmjs.com/package/vsts-npm-auth:

This is a bit old, not sure if you are still stuck, but for Windows you can use this npm package: https://www.npmjs.com/package/vsts-npm-auth:

npm install -g vsts-npm-auth
vsts-npm-auth -config path-to-your\.npmrc

这是来自Azure DevOps的更完整的文章,它引导您完成安装,.npmrc和身份验证以及发布: https://docs.microsoft.com/zh-CN/azure/devops/artifacts/npm/npmrc?view=azure-devops& ; tabs = windows :

Here is a more complete article from Azure DevOps that walks you through setup, .npmrc and auth and publishing: https://docs.microsoft.com/en-us/azure/devops/artifacts/npm/npmrc?view=azure-devops&tabs=windows:

如果您是在Linux或Mac上进行开发,则不支持vsts-npm-auth,我们建议按以下方式为$ HOME/.npmrc生成令牌.连接到提要"对话框会生成格式正确的令牌,您可以将其放入.npmrc文件中,使用期限为90天.

If you are developing on Linux or Mac, vsts-npm-auth is not supported and we recommend generating a token in the following manner for your $HOME/.npmrcThe Connect to feed dialog box generates an appropriately formatted token that you can place into your .npmrc file with a lifespan of 90 days.

  1. 从Azure Artifacts中,选择连接到源".
  2. 选择npm.
  3. 选择生成npm凭据.复制凭据以将其手动添加到您的用户.npmrc文件中.对于Windows,它位于%USERPROFILE%.npmrc中,如果上述方法不起作用,则可能很有用.对于Linux,它位于$ HOME/.npmrc中.

这篇关于npm发布天蓝色文物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 06:11