Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 317
Artyom Pranovich Avatar asked Sep 01 '17 10:09

Artyom Pranovich


People also ask

What is the default yarn registry?

It's usually https://registry.npmjs.org/ , but it's configurable.

Does yarn work with NPM registry?

Yarn can consume the same package. json format as npm, and can install any package from the npm registry. This will lay out your node_modules folder using Yarn's resolution algorithm that is compatible with the node.

Where does yarn look for Yarnrc?

Yarnrc files (named this way because they must be called . yarnrc. yml ) are the one place where you'll be able to configure Yarn's internal settings. While Yarn will automatically find them in the parent directories, they should usually be kept at the root of your project (often your repository).


2 Answers

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). And there you can specify custom config properties which yarn will look into first.

So that's how my .yarnrc file looks now.

registry "https://registry.yarnpkg.com"
like image 70
Artyom Pranovich Avatar answered Oct 11 '22 04:10

Artyom Pranovich


It is also possible to temporarily override the registry for one yarn command, without having to modify a file:

yarn --registry=https://registry.company.com/
like image 23
friederbluemle Avatar answered Oct 11 '22 06:10

friederbluemle