首页 > 解决方案 > 是否可以使用 yarn 从本地 Azure Artifacts 存储库中获取包?

问题描述

我们使用本地 Azure DevOps Server 2019。

在我的项目目录中,我有以下 .yarnrc 文件:

C:\xyz\tip\ui\EngagementCommon.UI [master ≡ +3 ~1 -1 !]> cat .\.yarnrc
registry "http://tfsserver.xyz.com:8080/tfs/DefaultCollection/_packaging/platform_catalog/npm/registry/"
C:\xyz\tip\ui\EngagementCommon.UI [master ≡ +3 ~1 -1 !]>

其中 platform_catalog 是提要的名称: 在此处输入图像描述

但是当我运行纱线时,我得到了这个:

C:\xyz\tip\ui\EngagementCommon.UI [master ≡ +3 ~1 -1 !]> yarn
yarn install v1.22.0
[1/4] Resolving packages...
error Couldn't find package "@platform/catalog" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
C:\xyz\tip\ui\EngagementCommon.UI [master ≡ +3 ~1 -1 !]> cat .\package.json|sls catalog

    "@platform/catalog": "^1.0.71",


C:\xyz\tip\ui\EngagementCommon.UI [master ≡ +3 ~1 -1 !]>

正如您在图片中看到的,该包位于我们的 Azure Artifacts npm 提要中,但是尽管 .yarnrc 文件要求,yarn 似乎根本没有检查它。

我错过了什么?

编辑 1

--verbose标志有助于了解正在发生的事情:

yarn --verbose
yarn install v1.22.0
verbose 0.1522596 Checking for configuration file "C:\\xyz\\tip\\UI\\EngagementCommon.UI\\.npmrc".
verbose 0.153013699 Found configuration file "C:\\xyz\\tip\\UI\\EngagementCommon.UI\\.npmrc".
verbose 0.154160399 Checking for configuration file "C:\\Users\\mkharitonov\\.npmrc".
verbose 0.15491 Found configuration file "C:\\Users\\mkharitonov\\.npmrc".
verbose 0.1557871 Checking for configuration file "C:\\Program Files\\nodejs\\etc\\npmrc".
verbose 0.1565483 Checking for configuration file "C:\\xyz\\tip\\UI\\EngagementCommon.UI\\.npmrc".
verbose 0.157282799 Found configuration file "C:\\xyz\\tip\\UI\\EngagementCommon.UI\\.npmrc".
verbose 0.158124099 Checking for configuration file "C:\\xyz\\tip\\UI\\.npmrc".
verbose 0.158851699 Checking for configuration file "C:\\xyz\\tip\\.npmrc".
verbose 0.159633599 Checking for configuration file "C:\\xyz\\.npmrc".
verbose 0.1642738 Checking for configuration file "C:\\xyz\\tip\\UI\\EngagementCommon.UI\\.yarnrc".
verbose 0.1689344 Checking for configuration file "C:\\Users\\mkharitonov\\.yarnrc".
verbose 0.1744512 Found configuration file "C:\\Users\\mkharitonov\\.yarnrc".
verbose 0.175591399 Checking for configuration file "C:\\Program Files\\nodejs\\etc\\yarnrc".
verbose 0.1781605 Checking for configuration file "C:\\xyz\\tip\\UI\\EngagementCommon.UI\\.yarnrc".
verbose 0.1789498 Checking for configuration file "C:\\xyz\\tip\\UI\\.yarnrc".
verbose 0.1796986 Checking for configuration file "C:\\xyz\\tip\\.yarnrc".
verbose 0.1804712 Checking for configuration file "C:\\xyz\\.yarnrc".
verbose 0.1856058 current time: 2020-02-20T15:19:28.047Z
[1/4] Resolving packages...
verbose 0.268615799 Performing "GET" request to "http://tfsserver.xyz.com:8080/tfs/DefaultCollection/_packaging/platform_catalog/npm/registry/@platform%2fcatalog".
verbose 0.2893787 Request "http://tfsserver.xyz.com:8080/tfs/DefaultCollection/_packaging/platform_catalog/npm/registry/@platform%2fcatalog" finished with status code 401.
verbose 0.3031119 Error: Couldn't find package "@platform/catalog" on the "npm" registry.
    at MessageError.ExtendableBuiltin (C:\Program Files (x86)\Yarn\lib\cli.js:721:66)
    at new MessageError (C:\Program Files (x86)\Yarn\lib\cli.js:750:123)
    at NpmResolver.<anonymous> (C:\Program Files (x86)\Yarn\lib\cli.js:50302:15)
    at Generator.next (<anonymous>)
    at step (C:\Program Files (x86)\Yarn\lib\cli.js:310:30)
    at C:\Program Files (x86)\Yarn\lib\cli.js:321:13
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
error Couldn't find package "@platform/catalog" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Yarn 得到 401 与自定义存储库的对话,但它默默地吞下它并继续检查 npm 中的包,它肯定不存在。我认为,纱线没有出现在 401 表面这一事实是一个可用性问题。

标签: npmyarnpkgazure-artifacts

解决方案


是否可以使用 yarn 从本地 Azure Artifacts 存储库中获取包?

回答这个问题,别着急,TFS 支持 yarn 消费神器。

在此处输入图像描述


错误消息与纱线本身更相关。

您可以尝试以下一些故障排除方法:

1) 是否有任何网络问题,例如防火墙等。

2) 确认没有为任何.yarnrc.npmrc文件设置不同的注册表。

如果上述检查后问题仍然存在,您可以添加--verbose命令以获取详细的执行日志并进行分析。


推荐阅读