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). Starting from the v2, they must be written in valid Yaml and have the right extension (simply calling your file .yarnrc
won't do).
Environment variables can be accessed from setting definitions by using the ${NAME}
syntax when defining the values. By default Yarn will require the variables to be present, but this can be turned off by using either ${NAME-fallback}
(which will return fallback
if NAME
isn't set) or ${NAME:-fallback}
(which will return fallback
if NAME
isn't set, or is an empty string).
Finally, note that most settings can also be defined through environment variables (at least for the simpler ones; arrays and objects aren't supported yet). To do this, just prefix the names and write them in snake case: YARN_CACHE_FOLDER
will set the cache folder (such values will overwrite any that might have been defined in the RC files - use them sparingly).
cacheFolder
The path where the downloaded packages are stored on your system. They'll be normalized, compressed, and saved under the form of zip archives with standardized names. The cache is deemed to be relatively safe to be shared by multiple projects, even when multiple Yarn instances run at the same time on different projects. For setting a global cache folder, you should use enableGlobalCache
instead.
httpsCaFilePath
changesetBaseRefs
The base git refs that the current HEAD is compared against in the version plugin. This overrides the default behavior of comparing against master, origin/master, upstream/master, main, origin/main, and upstream/main. Supports git branches, tags, and commits.
changesetIgnorePatterns
checksumBehavior
cloneConcurrency
compressionLevel
The compression level employed for zip archives, with 0 being 'no compression, faster' and 9 being 'heavy compression, slower'. The default is 'mixed', which is a variant of 9 where files may be stored uncompressed if the builtin libzip heuristic thinks it will lead to a more sensible result.
defaultLanguageName
defaultProtocol
Yarn is a modular package manager that can resolve packages from various sources. As such, semver ranges and tag names don't only work with the npm registry - just change the default protocol to something else and your semver ranges will be fetched from whatever source you select.
defaultSemverRangePrefix
deferredVersionFolder
enableColors
enableGlobalCache
enableHyperlinks
enableImmutableCache
enableImmutableInstalls
enableInlineBuilds
enableInlineHunks
enableMessageNames
enableMirror
enableNetwork
enableProgressBars
enableScripts
If false, Yarn will not execute the postinstall
scripts from third-party packages when installing the project (workspaces will still see their postinstall scripts evaluated, as they're assumed to be safe if you're running an install within them). Note that you can now also disable scripts on a per-package basis thanks to dependenciesMeta
.
enableTelemetry
If true (the default outside of CI environments), Yarn will periodically send anonymous data to our servers tracking some usage information such as the number of dependencies in your project, how many installs you ran, etc. Consult the Telemetry page for more details about it.
enableTimers
enableTransparentWorkspaces
If false, Yarn won't link workspaces just because their versions happen to match a semver range. Disabling this setting will require that all workspace accesses are made through the workspace:
protocol. This is usually only needed in some very specific circumstances.
httpProxy
httpsCertFilePath
httpsKeyFilePath
httpsProxy
ignorePath
immutablePatterns
initFields
installStatePath
logFilters
Defines overrides for log levels for message names or message text. Through this setting you can hide specific messages or give them a more important visibility.
text
Selects exactly one message that must match the given text. In case a message matches both code
-based and text
-based filters, the text
-based ones will take precedence over the code
-based ones.
pattern
Selects exactly one message that must match the given glob pattern. In case a message matches both pattern
-based and code
-based filters, the pattern
-based ones will take precedence over the other ones. Patterns can be overriden on a case-by-case basis by using the text
filter, which has precedence over pattern
.
lockfileFilename
networkConcurrency
networkSettings
Additional network settings, per hostname
*.example.com
The hostname to override settings for (glob patterns are supported)
httpsCaFilePath
See httpsCaFilePath
.
enableNetwork
See enableNetwork
.
httpProxy
See httpProxy
.
httpsCertFilePath
See httpsCertFilePath
.
httpsKeyFilePath
See httpsKeyFilePath
.
httpsProxy
See httpsProxy
.
nmHoistingLimits
Defines the highest point where packages can be hoisted. One of workspaces
(don't hoist packages past the workspace that depends on them), dependencies
(packages aren't hoisted past the direct dependencies for each workspace), or none
(the default, packages are hoisted as much as possible). This setting can be overriden per-workspace through the installConfig.hoistingLimits
field.
nmSelfReferences
Defines whether workspaces are allowed to require themselves - results in creation of self-referencing symlinks. This setting can be overriden per-workspace through the installConfig.selfReferences
field.
nmMode
If set to hardlinks-local
Yarn will utilize hardlinks to reduce disk space consumption inside node_modules
directories in a current project. With hardlinks-global
Yarn will use global content addressable storage to reduce node_modules
size across all the projects using this option.
nodeLinker
winLinkType
Applies to Windows only. If set to junctions
Yarn will use Windows junctions when linking workspaces into node_modules
directories, which are always absolute paths. If set to symlinks
Yarn will use symlinks, which will use relative paths, and is consistent with Yarn's behavior on non-Windows platforms. To create symlinks the Windows user running Yarn must have the create symbolic links
privilege. For this reason Yarn defaults to using junctions.
npmAlwaysAuth
npmAuditRegistry
npmAuthIdent
npmAuthToken
Defines the authentication credentials to use by default when accessing your registries (equivalent to _authToken
in the v1). If you're using npmScopes
to define multiple registries, the npmRegistries
dictionary allows you to override these credentials on a per-registry basis.
npmPublishAccess
npmAuditExcludePackages
npmAuditIgnoreAdvisories
npmPublishRegistry
npmRegistries
On top of the global configuration, registries can be configured on a per-scope basis (for example to instruct Yarn to use your private registry when accessing packages from a given scope). The following properties are supported:
//npm.pkg.github.com
This key represents the registry that's covered by the settings defined in the nested object. The protocol is optional (using https://npm.pkg.github.com
would work just as well).
npmRegistryServer
Defines the hostname of the remote server from where Yarn should fetch the metadata and archives when querying the npm registry. Should you want to define different registries for different scopes, see npmScopes
. To define the authentication scheme for your servers, see npmAuthToken
. The Hostname must use the HTTPS
protocol, but this can be changed by adding it to the unsafeHttpWhitelist
.
npmScopes
On top of the global configuration, registries can be configured on a per-scope basis (for example to instruct Yarn to use your private registry when accessing packages from a given scope). The following properties are supported:
my-company
This key represent the scope that's covered by the settings defined in the nested object. Note that it mustn't start with the @
character.
npmPublishRegistry
See npmPublishRegistry
.
npmRegistryServer
See npmRegistryServer
.
npmAlwaysAuth
See npmAlwaysAuth
.
npmAuthIdent
See npmAuthIdent
.
npmAuthToken
See npmAuthToken
.
packageExtensions
Some packages may have been specified incorrectly with regard to their dependencies - for example with one dependency being missing, causing Yarn to refuse it the access. The packageExtensions
fields offer a way to extend the existing package definitions with additional information. If you use it, consider sending a PR upstream and contributing your extension to the plugin-compat
database.
Note: This field is made to add dependencies; if you need to rewrite existing ones, prefer the resolutions
field.
webpack@*
Each key is a descriptor covering a semver range. The extensions will be applied to any package whose version matches the specified range. This is true regardless of where the package comes from, so no distinction on whether they come from git or a registry, for example. Only the version matters.
pnpEnableEsmLoader
pnpEnableInlining
pnpFallbackMode
pnpIgnorePatterns
An Array of glob patterns. Files matching the following locations (in term of relative path compared to the generated .pnp.cjs
file) will not be covered by PnP and will use the regular Node resolution. Typically only needed if you have subprojects that aren't yet part of your workspace tree.
pnpMode
If strict
(the default), Yarn won't allow modules to require packages they don't explicitly list in their own dependencies. If loose
, Yarn will allow access to the packages that would have been hoisted to the top-level under 1.x installs. Note that, even in loose mode, such calls are unsafe (hoisting rules aren't predictable) and should be discouraged.
pnpShebang
pnpUnpluggedFolder
preferAggregateCacheInfo
preferDeferredVersions
preferInteractive
preferReuse
preferTruncatedLines
progressBarStyle
Which style of progress bar should be used (only when progress bars are enabled). Valid values can be found here.
rcFilename
supportedArchitectures
Defines the systems for which Yarn should install packages.
cpu
The list of CPU architectures to cover. See https://nodejs.org/docs/latest/api/process.html#processarch for the architectures supported by Node.js
telemetryInterval
telemetryUserId
By default, we don't assign unique IDs in the telemetry we send, so we have no way to know which data originates from which project. This setting can be used to force a user ID to be sent to our telemetry server. Frankly, it's only useful in some very specific use cases. For example, we use it on the Yarn repository in order to exclude our own usage from the public dashboards (since we necessarily run Yarn more often here than anywhere else, the resulting data would be biased).
tsEnableAutoTypes
unsafeHttpWhitelist
This setting lists the hostnames for which using the HTTP protocol is allowed. Any other hostname will be required to use HTTPS instead. The reason behind this decision and more details can be found here.
Glob patterns are supported.
virtualFolder
Due to a particularity in how Yarn installs packages which list peer dependencies, some packages will be mapped to multiple virtual directories that don't actually exist on the filesystem. This settings tells Yarn where to put them. Note that the folder name must be __virtual__
.
yarnPath
The path of a Yarn binary, which will be executed instead of any other (including the global one) for any command run within the directory covered by the rc file. If the file extension ends with .js
it will be required, and will be spawned in any other case.
The yarnPath
setting is currently the preferred way to install Yarn within a project, as it ensures that your whole team will use the exact same Yarn version, without having to individually keep it up-to-date.