Searched for this information everywhere but can't find any clues. Like the .npmrc
I want to back it up in case of a data loss and/or sync it to other machines.
Something like yarn config where
or so would be cool.
~/.yarnrc
? :)
ah, goit it @arcanis ...
... but why am i seeing lastUpdateCheck
there? this prevents me from syncing the yarn config file among all my machines :(
i think the yarn config contents should be independent from the local state. save local state elsewhere like you do with lock files. reopen or raise this as a new issue?
You can actually move your yarnrc file into your project folder, and it will still work (that's useful for a number of use cases, such as offline mirrors). We probably can't make it the default behaviour tho, both for backward compatibility reasons, and because it makes sense for some other configuration values to be stored in a "global" yarnrc file.
sure, sounds good - but lastUpdateCheck? it is a local state. imagine you add it to your project folder, push that to a git repo and someone else pulls it? lastUpdateCheck won't be correct on the puller's machine. hence i am hesitant to sync that global yarnrc file among all my machines ...
I found at https://github.com/yarnpkg/yarn/blob/4a37df0a72922ac584bc84aaa8b8a077ce9d07ef/src/cli/commands/global.js#L89 that it looks at the node executable and calculates a prefix relative to that; it will then look in that prefix for a .yarnrc
file. so in the docker library node:6 image I was able to make /usr/local/.yarnrc
and actually set config globally.
Don't like it, but it works until yarn respects either the -g
flag (#1037) or /usr/local/etc/yarnrc
or something.
Per what @binarykitchen was saying, the "~/.yarnrc" should not contain local state or things like "# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.". RC files should be stateless files describing user configuration. In it's current state, you can't really add it to your dotfiles repo.
I just got tripped up by this so I tried to express @binarykitchen's point in a new issue: #4134
First, you can make yarn
verbose:
$ yarn config list --verbose
yarn config v1.22.5
verbose 0.597431427 Checking for configuration file "/home/yuri/src/yarn/.npmrc".
verbose 0.59781497 Checking for configuration file "/home/yuri/.npmrc".
verbose 0.597974459 Checking for configuration file "/usr/etc/npmrc".
verbose 0.598141219 Checking for configuration file "/home/yuri/src/yarn/.npmrc".
verbose 0.598267605 Checking for configuration file "/home/yuri/src/.npmrc".
verbose 0.598411356 Checking for configuration file "/home/yuri/.npmrc".
verbose 0.59856281 Checking for configuration file "/home/.npmrc".
verbose 0.599382032 Checking for configuration file "/home/yuri/src/yarn/.yarnrc".
verbose 0.599593107 Checking for configuration file "/home/yuri/.yarnrc".
verbose 0.599742477 Found configuration file "/home/yuri/.yarnrc".
verbose 0.600010627 Checking for configuration file "/usr/etc/yarnrc".
verbose 0.600149379 Checking for configuration file "/home/yuri/src/yarn/.yarnrc".
verbose 0.600264049 Checking for configuration file "/home/yuri/src/.yarnrc".
verbose 0.600378495 Checking for configuration file "/home/yuri/.yarnrc".
verbose 0.600490923 Found configuration file "/home/yuri/.yarnrc".
verbose 0.600689103 Checking for configuration file "/home/.yarnrc".
...
Second, if you're root (inside docker
?), for yarn
your home (userHome
) is at /usr/local/share
.
Third, $prefix
is either ${DESTDIR-}/usr/local
, or $userHome/.yarn
(the first that contains a bin
dir). Do note that root's home is at /usr/local/share
, not $prefix/share
.
Fourth, the function that does the checking is getPossibleConfigLocations()
. So basically it checks in:
./.yarnrc
~/.yarnrc or /usr/local/share/.yarnrc
$prefix/etc/yarnrc
../.yarnrc
../../.yarnrc
...
this.enableDefaultRc
is true
by default, but you can make it false
(--no-default-rc
). this.extraneousRcFiles
is populated by passing --use-yarnrc .myyarnrc
(possibly multiple times).
yarn config set
makes changes to the home config ($userHome/.yarnrc
).
I've noticed under a windows environment, using yarn2
If I run this in the project directory where there is an existing .yarnrc.yml file
Then the configuration is added to that
yarn config set enableGlobalCache true
If I run the same in a directory with no .yarnrc.yml file
Then the setting is added to the global configuration which under windows is typically
C:\Users\username\.yarnrc
This isn't an issue, it's quite useful, but I think the docs could do with being updated to include information about which configuration on which path is updated.
Also if you want different settings for yarn1 vs yarn2
Most helpful comment
Per what @binarykitchen was saying, the "~/.yarnrc" should not contain local state or things like "# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.". RC files should be stateless files describing user configuration. In it's current state, you can't really add it to your dotfiles repo.