首页 > 解决方案 > yarn 工作区的私有 npm 注册表有问题

问题描述

我正在尝试yarn workspaces使用具有私有依赖项的模块 - 以便在以下位置指定这样的一行.npmrc

//npm.pkg.github.com/:_authToken=this-is-some-fake-token

令牌显然不同。因此,当我yarn从该模块内部运行时,它会很好地抓取私有模块,但是当我尝试从工作区根目录运行它时,它会失败并出现错误,即在 npm 注册表上找不到给定的私有模块(但当然它不能- 它可能甚至不应该在那里寻找):

error Couldn't find package "@namespace/module@1.1.4" required by "one-of-workspaces@0.0.1" on the "npm" registry.

显然,在这种情况下,纱线不尊重.npmrc我已经放入工作区根目录,但为什么呢?或者它甚至不应该?并且不支持工作区模式下的私有注册表?

标签: npmyarnpkgyarn-workspaces

解决方案


Yarn 会尊重.npmrc你的主目录(不是 100% 确定 monorepo 根目录)。

您肯定缺少的.npmrc是提到@namespace应该从 GPR 中挑选包裹的那一行:

//npm.pkg.github.com/:_authToken=this-is-some-fake-token
@namespace:registry=https://npm.pkg.github.com/

推荐阅读