如何在 npm 中配置多个私有仓库和公共仓库? [英] How to config several private repository and public repository in npm?

查看:971
本文介绍了如何在 npm 中配置多个私有仓库和公共仓库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行 NPM 安装并拥有多个存储库来获取依赖项.我想首先查看公共关系的逻辑,如果它没有找到我的私人关系的 Artifcat

I want to run NPM install and to have multi repositories to get dependencies. The logic that I want first to look on public nexus and just if it didn't find the artifcat look for my private nexus

我为此添加了 .npmrc

I add .npmrc for this

registry=https://myRepo1.....
strict-ssl=false
https-proxy

我还需要添加公共 npm 吗?这个的网址是什么?让我们假设我还有另一个注册表,我如何添加它?(例如 https://myRepo2 )

Do I need to add the public npm also ? what is the url for this ? Lets assume that I have also another registry how I can add it also ? ( for example https://myRepo2 )

推荐答案

实现此目的的一种方法是设置私有 NPM 代理注册表,例如 Verdaccio.您可以将 .npmrc 配置为使用 Verdaccio 注册表而不是 npmjs.org,并且当您 npm installyarn add 一个模块时,您的私有注册表将首先被搜索,如果模块不在您的私有注册表中,然后它会在配置的上游或上行"注册表中查找.您可以配置多个上行链路注册表,如下所示:http://www.verdaccio.org/docs/en/uplinks.html

One way to accomplish this is to setup a private NPM proxy registry such as Verdaccio. You can configure your .npmrc to use your Verdaccio registry instead of npmjs.org and when you npm install or yarn add a module your private registry will be searched first, if the module isn't in your private registry it will then look in a configured upstream or "uplink" registry. You can configure multiple uplink registries as shown here: http://www.verdaccio.org/docs/en/uplinks.html

这篇关于如何在 npm 中配置多个私有仓库和公共仓库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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