简体   繁体   English

如何覆盖特定项目的全局纱线注册表

[英]How to override global yarn registry for particular project

For most projects I pull packages from the internal server, so it's been added by对于大多数项目,我从内部服务器中提取包,所以它是由

yarn config set registry http://custom-packages-server.com

But now in the new project I'd like to use the different (default) one, but use it in that particular project only.但现在在新项目中我想使用不同的(默认)一个,但只在那个特定项目中使用它。 As far as I understood if I run the following command inside of new project's directory据我所知,如果我在新项目的目录中运行以下命令

yarn config set registry https://registry.yarnpkg.com

it's going to update global registry value for all other projects as well, so they also will be looking for packages in the new place.它还将为所有其他项目更新全局注册表值,因此他们也将在新位置寻找包。

So is there a possibility in yarn to override global registry record for a specific project only?那么 yarn 是否有可能只覆盖特定项目的全局注册表记录?

Found the way how to achieve that.找到了如何实现这一目标的方法。

It turned out that you can use .yarnrc file inside the project's directory (yeah, pretty much the same like .npmrc ).事实证明,您可以在项目目录中使用.yarnrc文件(是的,与.npmrc几乎相同)。 And there you can specify custom config properties which yarn will look into first.在那里您可以指定纱线将首先查看的自定义配置属性。

So that's how my .yarnrc file looks now.这就是我的 .yarnrc 文件现在的样子。

registry "https://registry.yarnpkg.com"

也可以临时覆盖一个yarn命令的注册表,而无需修改文件:

yarn --registry=https://registry.company.com/
npm config delete registry

不要忘记删除yarn.lock<\/code> 。

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM