kra*_*lin 15 javascript npm yarnpkg
我正在尝试在我们的环境中设置Yarn 0.17.9,但我的注册表有问题.我们目前正在使用两个注册机构,官方npmjs和我们自己的内部网络注册表(Sinopia).
问题是我们正在使用内部工具通过--registry标志从一个或另一个中提取包npm install.yarn add没有--registry选项,我无法通过回退到npmjs全局设置自定义注册表.我试过.npmrc但它只为项目中的npm/yarn设置了一个注册表..yarnrc似乎没有工作,并被沉默.npmrc
有没有办法指定两个注册表(如果在第一个注册表中找不到包,则回退到第二个注册表)?或者为每个包指定不同的npm注册表?
对于 2021 年发现这一点的人来说,yarn 现在可以与范围、私有注册表和身份验证一起使用。
例如,我已经发布了私有包,例如@my-company-private-scope/my-packageVerdaccio ( Sinopia 的分支)服务器,我的.npmrc配置如下:
; Lines starting with ; are for .npmrc file comments
; yarn 1.22.10 seems to default registry to https://registry.yarnpkg.com
; no matter what I put here /shrug
; registry=https://registry.npmjs.com/
@my-company-private-scope:registry=https://npm.my-company.com/
//npm.my-company.com/:_authToken=TOKEN
; I did not seem to need this, as
; yarn still installed public and private packages successfully
; based on what ended up in my yarn.lock file
; //npm.my-company.com/:always-auth true
Run Code Online (Sandbox Code Playgroud)
看起来npm 也支持范围,虽然yarn unpublish不存在,npm unpublish @my-company-private-scope/my-package@1.0.1-5但也工作得很好。
我还不需要在多个私有服务器上尝试多个范围(尽管可能),但是我也没有看到它不能完美工作的任何充分理由。
您可以.yarnrc在项目的根目录中创建一个文件,并在该文件中写入以下行:
registry "https://registry.npmjs.org/"
Run Code Online (Sandbox Code Playgroud)
这将充当项目特定的存储库。
Yarn没有支持--registry标志为npm,但您可以在.yarnrc中设置注册表
如果你的.yarnrc被忽略,它可以使用以下方法从〜/ .yarnrc中复制出来:
yarn config set registry http://registry.com/registry//
Run Code Online (Sandbox Code Playgroud)
小智 6
您可以尝试在.npmrc和 中设置不同的注册表.yarnrc。
例如:在.npmrc:
registry=https://yourcompany/
virtual/:_authToken=credentials
always-auth=true
Run Code Online (Sandbox Code Playgroud)
always-auth=true需要是文件中的最后一行
并在.yarnrc:
registry "https://registry.yarnpkg.com"
Run Code Online (Sandbox Code Playgroud)
然后yarn add/ npm install+ private-pakage/public-packge 将起作用。
| 归档时间: |
|
| 查看次数: |
8889 次 |
| 最近记录: |