yarn config set — Yarn CLI reference

Set a configuration value

Docs/Reference/CLI/config/set

yarn config set

Set a configuration value

yarn config set <NAME> <VALUE>

This command writes a configuration setting to the project configuration file by default. Use -H,--home to write to the home configuration file instead.

Without --json, the value is interpreted according to the setting type: primitive values can be passed directly, while arrays and objects are parsed from JSON.

With --json, the value is always parsed as JSON before it is written.

Values are written in their canonical form, which yarn config get also prints: for example durations always get an explicit unit, using the largest one that represents them exactly (3h, 90m, 1d, 0s). The entries of settings accepting arbitrary keys (such as npmScopes or npmRegistries) are created when they don’t exist yet.

#--home, -Hboolean

Write to the home configuration file instead of the project file

#--jsonboolean

Parse the value as JSON before writing it

Examples#

Set a simple configuration setting (a string, a number, or a boolean)

yarn config set initScope myScope

Set a complex configuration setting (an Array) using the --json flag

yarn config set unsafeHttpWhitelist --json '["*.example.com", "example.com"]'

Set a complex configuration setting (an Object) using the --json flag

yarn config set npmScopes --json '{"my-company": {"npmRegistryServer": "https://npm.example.com"}}'

Set a configuration setting in the home configuration file

yarn config set -H initScope myScope