如何在纱线中使用多个npm注册表? [英] How do I use multiple npm registries in Yarn?

查看:79
本文介绍了如何在纱线中使用多个npm注册表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我们的环境中设置Yarn 0.17.9,但我的注册表有问题。我们目前正在使用两个注册机构,官方npmjs和我们自己的内部网络注册表(Sinopia)。

I'm trying to setup Yarn 0.17.9 in our environment but I have a problem with our registry. We are currently using two registries, official npmjs and our own registry on internal network (Sinopia).

问题是我们使用内部工具通过 npm install yarn add 没有--registry选项,我无法通过回退到npmjs全局设置自定义注册表。我尝试了 .npmrc ,但它只为项目中的npm / yarn设置了一个注册表。 .yarnrc 似乎不起作用并被 .npmrc

The problem is that we are using internal tool to pull packages from one or the other with --registry flag via npm install. yarn add doesn't have --registry option and I'm unable to set the custom registry globally with fallback to npmjs. I tried .npmrc but it sets only one registry for npm/yarn in project. .yarnrc doesn't seem to work and is silenced by .npmrc

有没有办法指定两个注册表(如果在第一个注册表中找不到包,则回退到第二个注册表)?或者为每个包指定不同的npm注册表?

Is there any way to specify two registries (fallback to second registry if the package is not found in the first one)? Or specify different npm registry per package?

推荐答案

纱线没有支持--registry标志为npm但你可以设置您在.yarnrc中的注册表

Yarn doesn't have support --registry flag as npm but you can set up your registry in .yarnrc

如果您的.yarnrc被忽略,可以使用以下命令将其复制出〜/ .yarnrc:

If your .yarnrc is being ignored it can be copied out of the ~/.yarnrc using:

yarn config set registry http://registry.com/registry//

这篇关于如何在纱线中使用多个npm注册表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆