Managing Yarn with Environment Variables and .yarnrc Configuration
In the last tutorial we introduced you to yarn's configuration and the package.json file. The tutorial you are about to read will examine environment variables, as well as the .yarnrc file.
envvars
The environment variables defined in the process.env enable you to configure additional Yarn features.
CHILD_CONCURRENCY
Process.env.CHILD_CONCURRENCY=#number#
This controls the number of child processes that run in parallel to build node modules.
When you set this variable to 1, it will cause the node modules to be built sequentially which can avoid linker errors on windows with node-gyp.
npm_config
in order to maintain backward compatibility with npm, Yarn permits you to pass down npm configuration via environment variables. For example, the ?build-from-source npm CLI flag will become: npm_config_build_from_source=true
.yarnrc
.yarnrc files enable you to configure additional Yarn features. The config command can also be used to set these options. Yarn will merge the .yarnrc files up the file tree.
yarn-offline-mirror
yarn-offline-mirror "./packages-cache"
The yarn-offline-mirror field maintains offline copies of your packages for more repeatable and reliable builds.
You should make this value a relative file path or you set it to false so as to disable the mirror (default).
yarn-offline-mirror-pruning
yarn-offline-mirror-pruning true
This controls automatic pruning of the offline mirror.
The value should be a boolean, defaults to false.
yarn-path
yarn-path "./bin/yarn"
The yarn-path will instruct yarn to defer to another Yarn binary for execution. This field is useful when you need to bundle Yarn into your repository, it ensures that everyone uses the same version for consistency. This feature was introduced in Yarn 1.0, so all the developers must have Yarn >= 1.0 installed.
The value must be a relative file path, or false to disable (default).
disable-self-update-check
disable-self-update-check true
During package installations, Yarn will provide you with upgrade instructions, if you have an outdated CLI installation. The value should be a boolean, defaults to false.
child-concurrency
child-concurrency #number#
The child-concurrency field controls the number of child processes run parallely to build node modules.
When you set this number to 1, it will cause the node modules to be built sequentially which can avoid linker errors on windows with node-gyp.
unsafe-disable-integrity-migration
unsafe-disable-integrity-migration false
Setting this to false enables the yarn.lock checksum migration (enabling sha512 support). It causes lockfile format change. This is going to be the default starting from version 2.0.
CLI arguments
When you set --<command>.<flag> <value> in .yarnrc, it is usually the same as running yarn <command> --<flag> <value>.
For example:
CMD: cat ```.yarnrc```
Output:
install.check-files true
The above command is the same running yarn install --check-files
Example:
CMD: ````cat .yarnrc```
--cache-folder /tmp/yarn-cache/```
MD: ```yarn cache dir``
Output:
/tmp/yarn-cache/v1
Previous:
Yarn Configuration and Package.json file overview.
Next:
Understanding and Managing the yarn.lock configuration file.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/yarn/yarn-envvars-and-yarnrc-files.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics