Settings (.yarnrc.yml)
Reference for all .yarnrc.yml configuration settings in Yarn.
Settings (.yarnrc.yml)
Allowed fields in .yarnrc.yml files
JSON schema for editor validation and autocompletion.
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).
Nullable settings accept explicit null values. Omission lets configuration sources and defaults apply; null is an explicit value, with setting-specific behavior.
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).
Path where the downloaded packages are stored on your system.
Packages are normalized and saved as zip archives with standardized names (compressed according to compressionLevel). This folder is only used when enableGlobalCache is false; otherwise the archives are stored in the global cache inside globalFolder. Defaults to .yarn/cache in the project.
When this setting is left to its default, archives the project no longer references are removed from the folder at the end of each install; they're kept when cacheFolder is set explicitly.
# Store the project cache in a custom folder (requires `enableGlobalCache: false`).
cacheFolder: ".cache/yarn"
List of git refs against which Yarn will compare your branch when it needs to detect changes.
Supports git branches, tags, and commits. The default configuration will compare against main and master.
# Compare changes against the main branch only.
changesetBaseRefs:
- "main"
- "origin/main"
# Compare changes against both stable branch names used by the project.
changesetBaseRefs:
- "main"
- "origin/main"
- "master"
- "origin/master"
List of glob patterns whose changes affect every workspace.
When a file matching one of these patterns (relative to the project root) changed, yarn workspaces list --since and yarn tasks run --affected consider every workspace as changed, similar to turbo's globalDependencies.
# Rebuild everything when the Node version or patches change.
changesetGlobalFiles:
- ".nvmrc"
- "patches/**"
Amount of git clone operations that Yarn will run at the same time.
We by default limit it to 2 concurrent clone operations. The value must be at least 1.
# Example
cloneConcurrency: 4
Compression level employed for zip archives
Values from 0 (no compression) to 9 (heavy compression) select the Deflate level used for the archives stored in the cache, and are accepted as integers or strings. When the setting is omitted or null (the default), archives are stored without compression. The mixed value from earlier Yarn versions is rejected.
# Compress cache archives as much as possible.
compressionLevel: 9
# Store cache archives without compression (the default).
compressionLevel: null
Default prefix used in semver ranges created by yarn add and similar commands.
Possible values are caret (the default), tilde, and exact; the symbolic aliases ^, ~, =, *, and the empty string are also accepted.
# Pin the exact version when adding dependencies.
defaultSemverRangePrefix: "exact"
# Only accept patch updates of new dependencies.
defaultSemverRangePrefix: "tilde"
Folder where the versioning files are stored.
Deferred version decisions (recorded by yarn version when preferDeferredVersions is enabled, and applied by yarn version apply) are written to this folder. Relative paths are resolved from the project root.
# Example
deferredVersionFolder: ".changes"
Define whether Yarn should automatically deduplicate dependencies.
When enabled, Yarn automatically deduplicates dependencies during full-project installs using the highest strategy, reusing the highest compatible versions already present in the dependency graph. This also applies to installs triggered by commands such as yarn add and automatic installs before running scripts. Focused installs preserve the lockfile's resolutions, and explicit dedupe commands retain control over their patterns and checks. Immutable installs fail if deduplication would change the lockfile.
# Example
enableAutoDedupe: true
Define whether constraints should run on every install.
If true, Yarn will run your constraints right after finishing its installs. This may help decrease the feedback loop delay by catching errors long before your CI would even report them.
# Example
enableConstraintsChecks: true
Define whether the cache should be shared between all local projects.
If true (the default), Yarn will store the cache files into a folder located within globalFolder instead of respecting cacheFolder.
Define whether Yarn should attempt to check for malicious changes.
If true, yarn install refreshes the package metadata stored in the lockfile from the remote registries (as with --refresh-lockfile) and never takes the "already up-to-date" shortcut. Immutable installs are also enabled, unless enableImmutableInstalls is set explicitly. These checks make installs slower, so you should only run them on branches managed by users outside your circle of trust.
Yarn will automatically enable the hardened mode on GitHub pull requests from public repository. Should you want to disable it, explicitly set it to false in your yarnrc file (or set YARN_ENABLE_HARDENED_MODE=0).
Define whether to allow adding/removing files from the cache or not.
If true, Yarn will refuse to change the cache in any way, whether it would add files or remove them, and will abort installs instead of letting that happen.
Define whether to allow adding/removing entries from the lockfile or not.
If true, Yarn refuses to change the lockfile and aborts the install instead, before the project gets linked. Other files can be protected via immutablePatterns. Defaults to true in CI environments (or when hardened mode is enabled), and false otherwise.
Define whether to mirror local cache entries into the global cache or not.
If true (the default), Yarn will use the global folder as indirection between the network and the actual cache. This is only useful if enableGlobalCache is explicitly set to false, as otherwise the cache entries are persisted to the global cache no matter what.
Define whether remote network requests are allowed or not.
If false, Yarn will never make any request to the network by itself, and will throw an exception rather than let it happen. It's a very useful setting for CI, which typically want to make sure they aren't loading their dependencies from the network by mistake.
Define whether animated progress bars should be shown or not.
If true, Yarn shows progress bars for long-running events. Enabled by default when the output is a terminal.
# Example
enableProgressBars: true
Define whether to run postinstall scripts or not.
If false (the default), Yarn will not execute the build scripts (such as postinstall) of 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).
The dependenciesMeta[].built field of the root manifest overrides this setting on a per-package basis, so you can allow the scripts of specific packages while keeping enableScripts disabled, or disable specific packages when it's enabled.
Define whether SSL errors should fail requests or not.
If false, SSL certificate errors will be ignored
Define whether to print the time spent running each sub-step or not.
If false, Yarn will not print the time spent running each sub-step when running various commands. This is only needed for testing purposes, when you want each execution to have exactly the same output as the previous ones.
Define whether pure semver ranges should allow workspace resolution or not.
If false, Yarn won't link workspaces just because their versions happen to match a semver range. Disabling this setting will require all workspaces to reference one another using the explicit workspace: protocol.
This setting is usually only needed when your project needs to use the published version in order to build the new one (that's for example what happens with Babel, which depends on the latest stable release to build the future ones).
Path where all files global to the system will be stored.
Stores the global package cache, the metadata cache, the content-addressed store, and other files shared between projects. Defaults to %LOCALAPPDATA%\Yarn\zpm on Windows (or AppData\Local\Yarn\zpm inside your home directory if LOCALAPPDATA isn't set), to $XDG_DATA_HOME/yarn/zpm when XDG_DATA_HOME is set, and to .yarn/zpm inside your home directory otherwise. If .yarn/zpm already exists inside your home directory and the platform-specific folder doesn't, Yarn keeps using .yarn/zpm.
# Example
globalFolder: "${HOME}/.yarn/zpm"
Proxy to use when making an HTTP request.
Applies to requests whose URL uses the http: protocol; see httpsProxy for https: URLs.
# Example
httpProxy: "http://proxy:4040"
Number of times to retry a failed HTTP request.
Requests are retried when they fail with a network error or a 408, 413, 429, or 5xx status code. Yarn waits between attempts with an exponential backoff capped at 10 seconds. Set it to 0 to disable retries.
# Example
httpRetry: 5
Amount of time to wait before cancelling pending HTTP requests.
The timeout covers the whole request, from the connection to the end of the response body. The duration accepts the ms, s, m, h, d, and w units; values without unit are in milliseconds (as in Yarn 4), so 60000 is one minute.
# Give up on requests after thirty seconds.
httpTimeout: "30s"
# Be more patient on slow networks.
httpTimeout: "5m"
Path to a file containing one or multiple Certificate Authority signing certificates.
The certificates are trusted in addition to the system ones. Can be set for specific hosts through networkSettings.
# Example
httpsCaFilePath: "./exampleCA.pem"
Path to a file containing a certificate chain in PEM format.
Client certificate presented to the servers that request one; it must be combined with httpsKeyFilePath. Can be set for specific hosts through networkSettings.
# Example
httpsCertFilePath: "./exampleCert.pem"
Path to a file containing a private key in PEM format.
Private key matching the client certificate set in httpsCertFilePath. Can be set for specific hosts through networkSettings.
# Example
httpsKeyFilePath: "./exampleKey.pem"
Define a proxy to use when making an HTTPS request.
Applies to requests whose URL uses the https: protocol; see httpProxy for http: URLs.
# Example
httpsProxy: "http://proxy:4040"
Array of file patterns whose content won't be allowed to change if enableImmutableInstalls is set.
Patterns are relative to the project root. When immutable installs are enabled, yarn install hashes the matching files before and after the install, and fails if they changed.
# Protect PnP loader files during immutable installs.
immutablePatterns:
- "**/.pnp.*"
# Protect both generated install artifacts and checked-in package archives.
immutablePatterns:
- ".pnp.cjs"
- ".pnp.loader.mjs"
- ".yarn/cache/**"
Scope used when creating packages via the init command.
Accepted for compatibility with earlier Yarn versions, but not currently used: yarn init doesn't read this setting.
Array of .env files which will get injected into any subprocess spawned by Yarn.
By default Yarn will automatically inject the variables stored in the .env.yarn file, but you can use this setting to change this behavior.
Note that adding a question mark at the end of the path will silence the error Yarn would throw should the file be missing, which may come in handy when declaring local configuration files.
# Load the default Yarn env file and fail if it is missing.
injectEnvironmentFiles:
- ".env.yarn"
# Load one shared file and one optional local override.
injectEnvironmentFiles:
- ".env.yarn"
- ".env.local?"
Scope of lazy installs.
With all, lazy installs always install the entire project, even after a focused install.
With focused, lazy installs keep a focused install focused: when the previous install was made by yarn workspaces focus, they install the workspaces it covered, plus the active workspace and the workspaces it depends on if they weren't part of it. A lazy install never starts a focus by itself: on a fresh clone, or when the previous install was a full one (yarn install), it installs the entire project in both modes. The same goes when the manifests no longer match the lockfile, or when a setting that affects installs changed, since Yarn then has to resolve the whole project.
# Let the commands extend a focused install with the workspaces they need, rather than install the entire project.
lazyInstallMode: "focused"
Alter the log levels for emitted messages.
This can be used to hide specific messages, or instead make them more prominent. Each filter matches messages by exact text or by glob pattern (a pattern doesn't need to cover the whole message), and assigns them a new level (info, warning, error, or discard to hide them). Filters are evaluated in order, and the first one matching a message decides its level. Colors are stripped from messages before matching.
# Hide all messages matching a glob pattern.
logFilters:
-
pattern: "optional dependency * skipped"
level: "discard"
# Upgrade one exact log message to an error.
logFilters:
-
text: "Package build failed"
level: "error"
Amount of HTTP requests that are allowed to run at the same time.
We default to 100 concurrent requests, but it may be required to limit it even more when working behind proxies that can't handle large amounts of traffic.
# Example
networkConcurrency: 16
Additional network settings, per hostname
Keys are glob patterns matched against the hostname of each request; when several patterns match, the longest one takes precedence. Each entry can override enableNetwork, httpsCaFilePath, httpsCertFilePath, and httpsKeyFilePath for the matching hosts. A CA file set here is trusted in addition to the global httpsCaFilePath, while setting httpsCertFilePath or httpsKeyFilePath here replaces both global client certificate settings for the matching hosts.
# Disable network access for one host pattern.
networkSettings:
"*.example.com":
enableNetwork: false
# Use a custom CA certificate for an internal registry.
networkSettings:
"registry.corp.example":
httpsCaFilePath: "./certs/corp-ca.pem"
Highest point where packages can be hoisted.
Replacement of the former nohoist setting. Possible values are:
- If
none(the default), packages are hoisted as per the usual rules. - If
workspaces, packages won't be hoisted past the workspace that depends on them. - If
dependencies, transitive dependencies also won't be hoisted past your direct dependencies.
This setting can be overridden on a per-workspace basis using the installConfig.hoistingLimits field.
# Keep each workspace's dependencies inside its own node_modules folder.
nmHoistingLimits: "workspaces"
Define whether workspaces are allowed to require themselves.
If false, Yarn won't create self-referencing symlinks when using nodeLinker: node-modules. This setting can be overridden on a per-workspace basis using the installConfig.selfReferences field.
Define how to copy files to their target destination.
Possible values are:
- If
classic, regular copy or clone operations are performed. - If
hardlinks-global, hardlinks to a global content-addressable store will be used. - If
hardlinks-local, hardlinks will only be created between similar packages from the same project.
For compatibility with the ecosystem, the default is classic.
# Save disk space by hardlinking files from a store shared between projects.
nmMode: "hardlinks-global"
Define how Node packages should be installed.
Yarn supports three ways to install your project's dependencies, based on the nodeLinker setting. Possible values are:
- If
pnp, a single Node.js loader file will be generated. - If
pnpm, anode-moduleswill be created using symlinks and hardlinks to a global content-addressable store. - If
node-modules, a regularnode_modulesfolder just like in Yarn Classic or npm will be created.
# Use Plug'n'Play installs.
nodeLinker: "pnp"
# Use a traditional node_modules install.
nodeLinker: "node-modules"
Define whether Yarn should enable Node.js package maps for installs that support them.
If true, Yarn will inject Node.js' experimental --experimental-package-map option into NODE_OPTIONS when using nodeLinker: node-modules or nodeLinker: pnpm and a package map has been generated.
Define how Yarn should generate Node.js package maps.
Possible values are:
- If
standard(the default), package maps will reflect the dependency graph and reject undeclared dependencies. - If
loose, package maps will reflect the hoisted node_modules layout and mimic Node.js resolution more closely.
This setting applies to both nodeLinker: node-modules and nodeLinker: pnpm.
# Mimic the Node.js resolution of the hoisted node_modules layout.
nodePackageMapType: "loose"
Path where the pnpm store will be stored
By default, the store is stored in the node_modules/.yarn/store folder of the project. Sometimes in CI scenario's it is convenient to store this in a different location so it can be cached and reused.
# Use the default virtual store inside node_modules.
pnpmStoreFolder: "node_modules/.yarn/store"
# Move the virtual store to a cacheable project folder.
pnpmStoreFolder: ".cache/.pnpm"
Define whether to use junctions or symlinks when creating links on Windows.
Possible values are:
- If
junctions, Yarn will use Windows junctions when linking workspaces intonode_modulesdirectories, which are always absolute paths. - If
symlinks, Yarn will use symlinks, which will use relative paths, and is consistent with Yarn's behavior on non-Windows platforms.
# Use junctions on Windows machines where symlinks can't be created.
winLinkType: "junctions"
Define whether to always send authentication credentials when querying the npm registry.
If true, authentication credentials will always be sent when sending requests to the registries. Requests for scoped packages already include the configured credentials, so this is only needed for unscoped packages, for example when you configured the registry to reference a private npm mirror.
Define the registry to use when auditing dependencies.
If not explicitly set, the value of npmRegistryServer will be used.
# Example
npmAuditRegistry: "https://registry.npmjs.org"
Username and password (username:password), or their Base64 encoding, to use for npm authentication.
Replacement of the former _auth setting. Because it requires storing unencrypted values in your configuration, npmAuthToken should be preferred when possible.
# Example
npmAuthIdent: "username:password"
Define the authentication token to use by default when accessing your registries.
Replacement of the former _authToken settings. If you're using npmScopes to define multiple registries, the npmRegistries dictionary allows you to override these credentials on a per-registry basis.
# Example
npmAuthToken: "ffffffff-ffff-ffff-ffff-ffffffffffff"
Define the default access to use when publishing packages to the npm registry.
Valid values are public and restricted, but restricted usually requires to register for a paid plan (this is up to the registry you use). Can be overridden on a per-package basis using the publishConfig.access field.
# Example
npmPublishAccess: "public"
Define whether to attach a provenance statement when publishing packages to the npm registry.
Accepted for compatibility with earlier Yarn versions, but not currently used: yarn npm publish only generates a provenance statement when called with --provenance, or when the publishConfig.provenance field of the package is set.
Array of package name glob patterns to exclude from yarn npm audit.
Matching packages aren't sent to the audit endpoint. Patterns passed through yarn npm audit --exclude are added to this list.
# Exclude one package from audit reports.
npmAuditExcludePackages:
- "known_insecure_package"
# Exclude a family of internal test fixtures.
npmAuditExcludePackages:
- "@example/fixture-*"
- "legacy-test-helper"
Array of advisory ID glob patterns to ignore from yarn npm audit results.
Matching advisories are removed from the report. Patterns passed through yarn npm audit --ignore are added to this list.
# Ignore a single advisory ID.
npmAuditIgnoreAdvisories:
- "1234567"
# Ignore a short-term allowlist of advisory IDs while patches are pending.
npmAuditIgnoreAdvisories:
- "1234567"
- "GHSA-xxxx-yyyy-zzzz"
Define the registry to use when pushing packages.
If not explicitly set, the value of npmRegistryServer will be used. Overridden by publishConfig.registry.
# Example
npmPublishRegistry: "https://npm.pkg.github.com"
Per-registry configurations.
Legacy-compatible per-registry npm authentication settings. New configurations may prefer sourceRules for registry and ecosystem policy.
Each key is either the registry URL (https://npm.pkg.github.com) or the same URL without its protocol (//npm.pkg.github.com), which then applies whatever the protocol; trailing slashes are ignored. When both forms are set for a registry, only the entry with the protocol is used. Each entry accepts npmAlwaysAuth, npmAuthIdent, and npmAuthToken, which override the global settings for requests to that registry. yarn npm login stores the tokens it obtains here.
# Configure authentication for the public npm registry.
npmRegistries:
"https://registry.npmjs.org":
npmAuthToken: "${NPM_TOKEN}"
# Always send auth for a private registry.
npmRegistries:
"https://npm.pkg.github.com":
npmAlwaysAuth: true
npmAuthToken: "${GITHUB_TOKEN}"
Define the registry to use when fetching packages.
Should you want to define different registries for different packages, see packageRules. To define the authentication scheme for your servers, see npmAuthToken. The url must use HTTPS by default, but this can be changed by adding it to the unsafeHttpWhitelist.
# Example
npmRegistryServer: "https://registry.example.org"
Define the PyPI registry to use when fetching Python packages.
Used by the pypi: protocol. Must point to the root of a Simple Repository API (PEP 503 / PEP 691), which is the URL you'd give to pip --index-url; https://pypi.org is accepted as an alias for https://pypi.org/simple/. Can be overridden for specific packages using packageRules.
# Use an internal PyPI-compatible registry.
pypiRegistryServer: "https://pypi.example.org/simple/"
Username and password (username:password) to use for PyPI authentication.
Sent as Authorization: Basic credentials when querying PyPI indexes. Takes precedence over pypiAuthToken when both are set. Credentials are only sent to the host serving the index; artifacts hosted elsewhere are downloaded without them. Can be set per package through packageRules, or per index through sourceRules.
# Example
pypiAuthIdent: "${PYPI_USERNAME}:${PYPI_PASSWORD}"
Token to use for PyPI authentication.
Sent as an Authorization: Bearer token when querying PyPI indexes. Credentials are only sent to the host serving the index; artifacts hosted elsewhere are downloaded without them. Can be set per package through packageRules, or per index through sourceRules.
# Example
pypiAuthToken: "${PYPI_TOKEN}"
Newest macOS version that macOS wheels may require.
Wheels whose macosx_X_Y platform tag requires a newer macOS version are ignored when selecting the wheels to lock for macOS. The value is a major.minor version.
# Example
pypiMacosTarget: "15.0"
Newest glibc version that manylinux wheels may require.
Wheels whose manylinux_X_Y platform tag requires a newer glibc are ignored when selecting the wheels to lock for Linux. The value is a major.minor version.
# Example
pypiManylinuxTarget: "2.28"
Minimum age of a PyPI release file required before installation.
Files uploaded more recently than this duration are ignored (the equivalent of uv's exclude-newer). It relies on the upload times reported by PEP 691 indexes; files whose index doesn't report an upload time are never filtered. Can be overridden per package through packageRules, or per index through sourceRules.
# Ignore files published less than two days ago.
pypiMinimalAgeGate: "2d"
Base URL of the python-build-standalone releases.
Managed CPython builds are downloaded from <mirror>/<release>/, along with the SHA256SUMS file used to verify them. The name of the latest release is still read from the python-build-standalone repository on GitHub.
# Example
pythonDownloadMirror: "https://artifacts.example.com/python-build-standalone/releases/download"
Define whether Yarn may download managed Python interpreters.
If true (the default), Yarn downloads a python-build-standalone CPython build when no interpreter matching the requested pythonVersion is found, either in the global folder or on the PATH. If false, the install fails instead.
Define which Python interpreters Yarn should prefer.
Possible values are:
- If
managed(the default), Yarn uses a python-build-standalone build already downloaded in the global folder, then an interpreter found on thePATH, and finally downloads a build (unlesspythonDownloadsisfalse). - If
system, interpreters found on thePATHare preferred over the managed builds.
The YARN_PYTHON_EXECUTABLE environment variable can be used to force a specific interpreter.
# Prefer the interpreters installed on the system.
pythonPreference: "system"
Python version used for PyPI packages and venv islands.
Accepts a major.minor (3.12) or major.minor.patch (3.12.11) version. It's used to evaluate environment markers and requires-python when resolving pypi: dependencies, and to pick the interpreter of the venv islands. The .python-version file at the root of the project takes precedence over this setting, and each island can override both through a .python-version file in the folder of one of its workspaces, or its own pythonVersion field (see unstableIslands).
# Example
pythonVersion: "3.13"
Per-scope registry configurations.
Legacy-compatible per-scope npm registry, authentication, and npmMinimalAgeGate settings. New configurations may prefer packageRules.
Each key is a scope name, without the leading @. Each entry accepts npmRegistryServer, npmPublishRegistry, npmAlwaysAuth, npmAuthIdent, npmAuthToken, and npmMinimalAgeGate, which apply to the packages of that scope. A scope's npmMinimalAgeGate replaces the global value for the packages of that scope, and can be stricter or looser (0 disables the gate); sourceRules and packageRules still take precedence over it.
# Route one scope to a GitHub Packages registry.
npmScopes:
my-company:
npmRegistryServer: "https://npm.pkg.github.com"
npmAuthToken: "${GITHUB_TOKEN}"
# Use a different registry only when publishing a scope.
npmScopes:
my-company:
npmPublishRegistry: "https://npm.pkg.github.com"
npmRegistryServer: "https://registry.npmjs.org"
# Install fresh releases of an internal scope immediately.
npmScopes:
my-company:
npmRegistryServer: "https://npm.pkg.github.com"
npmMinimalAgeGate: "0"
Package-specific configuration rules.
Rules are applied in order, and later matching rules override earlier ones. Each rule must define at least one of ecosystemFilter (npm or pypi) or packageFilter (a package name glob pattern). Besides the filters, a rule accepts npmRegistryServer, npmPublishRegistry, npmMinimalAgeGate, npmAlwaysAuth, npmAuthIdent, npmAuthToken, pypiRegistryServer, pypiMinimalAgeGate, pypiAuthIdent, and pypiAuthToken, which override the matching global settings for the packages it matches. Package rules take precedence over npmScopes, npmRegistries, and sourceRules.
# Route one npm scope to a private registry.
packageRules:
-
ecosystemFilter: "npm"
packageFilter: "@my-scope/*"
npmRegistryServer: "https://registry.example.org"
# Disable the npm minimum age gate for one package.
packageRules:
-
packageFilter: "specific-package"
npmMinimalAgeGate: "0s"
# Route internal Python packages to a private index.
packageRules:
-
ecosystemFilter: "pypi"
packageFilter: "mycompany-*"
pypiRegistryServer: "https://pypi.example.org/simple/"
pypiAuthToken: "${PYPI_TOKEN}"
pypiMinimalAgeGate: "0s"
Source-specific configuration rules.
Rules are applied in order, and later matching rules override earlier ones. Each rule must define at least one of ecosystemFilter (npm or pypi) or registryFilter (a registry or index URL, compared after normalizing trailing slashes). Besides the filters, a rule accepts npmMinimalAgeGate, npmAlwaysAuth, npmAuthIdent, npmAuthToken, pypiMinimalAgeGate, pypiAuthIdent, and pypiAuthToken, which override the matching global settings for the requests sent to the sources it matches. Source rules take precedence over npmScopes and npmRegistries, and are themselves overridden by packageRules.
# Configure authentication for one npm registry.
sourceRules:
-
ecosystemFilter: "npm"
registryFilter: "https://registry.example.org"
npmAuthToken: "${NPM_TOKEN}"
# Use a different npm age gate for all npm sources.
sourceRules:
-
ecosystemFilter: "npm"
npmMinimalAgeGate: "6h"
# Authenticate the requests sent to a private PyPI index.
sourceRules:
-
ecosystemFilter: "pypi"
registryFilter: "https://pypi.example.org/simple/"
pypiAuthIdent: "${PYPI_USERNAME}:${PYPI_PASSWORD}"
Extend the package definitions of your dependencies; useful to fix third-party issues.
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 instead.
# Add a missing regular dependency to a third-party package.
packageExtensions:
"some-package@*":
dependencies:
lodash: "^4.17.21"
# Declare an optional peer dependency for a package that forgot its metadata.
packageExtensions:
"webpack-plugin-example@*":
peerDependencies:
webpack: "*"
peerDependenciesMeta:
webpack:
optional: true
Folder where patch files will be written to.
Used by yarn patch-commit --save, which writes the patch file there and updates the manifests to reference it through the patch: protocol. Relative paths are resolved from the project root.
# Example
patchFolder: "patches"
Define whether to store the PnP data in the generated file or not.
If false, Yarn will generate an additional .pnp.data.json file.
Define whether to allow packages to rely on the builtin PnP fallback mechanism.
Possible values are:
- If
all, all packages can access dependencies made available in the fallback. - If
dependencies-only(the default), dependencies will have access to them but not your workspaces. - If
none, no packages will have access to them.
# Disable the fallback to catch every undeclared dependency.
pnpFallbackMode: "none"
Array of file glob patterns that should be forced to use the default CommonJS resolution.
Files matching those locations will not be covered by PnP and will use the regular Node.js resolution algorithm. Typically only needed if you have subprojects that aren't yet part of your workspace tree.
# Exclude one legacy subproject from Plug'n'Play resolution.
pnpIgnorePatterns:
- "./legacy/*"
# Exclude multiple generated package folders.
pnpIgnorePatterns:
- "./examples/*"
- "./fixtures/*"
String prepended to the generated PnP loader.
Written as the first line of the generated .pnp.cjs file.
# Example
pnpShebang: "#!/usr/bin/env -S node --no-warnings"
Path where unplugged packages are stored.
While Yarn attempts to reference and load packages directly from their zip archives, it may not always be possible. In those cases, Yarn will extract the files to the unplugged folder. Relative paths are resolved from the project root.
# Example
pnpUnpluggedFolder: ".yarn/unplugged-packages"
Define whether to use deferred versioning by default or not.
If true, deferred versioning by default when running the yarn version family of commands.
Define whether to use interactive prompts by default or not.
Accepted for compatibility with earlier Yarn versions, but not currently used: no command reads this setting.
Define whether to reuse most common dependency ranges or not when adding dependencies to a package.
If true, yarn add will attempt to reuse the most common dependency range in other workspaces.
Define whether to truncate lines that would go beyond the size of the terminal or not.
Accepted for compatibility with earlier Yarn versions, but not currently used: Yarn doesn't read this setting.
Systems for which Yarn should install packages.
Accepts a single entry or a list of entries. Fields within each entry form a cross product; list entries are matched independently. An omitted setting, null, or an empty list uses the current system. Each field accepts a string, an array of strings, or null to cover all values; an empty field array covers none. Omitted fields default to current.
# Install packages for the current platform plus Linux x64.
supportedArchitectures:
os:
- "current"
- "linux"
cpu:
- "current"
- "x64"
libc:
- "current"
- "glibc"
# Pre-resolve common macOS and Linux variants for a mixed team.
supportedArchitectures:
os:
- "darwin"
- "linux"
cpu:
- "x64"
- "arm64"
libc:
- "glibc"
- "musl"
# Match macOS arm64 and Linux x64 independently, with any C library.
supportedArchitectures:
-
os: "darwin"
cpu: "arm64"
libc: null
-
os: "linux"
cpu: "x64"
libc: null
List of operating systems to cover.
Accepts current and the values of Node.js' process.platform (for example darwin, linux, or win32).
List of CPU architectures to cover.
See https://nodejs.org/docs/latest/api/process.html#processarch for the architectures supported by Node.js
The list of standard C libraries to cover.
Accepts current, glibc, and musl.
Define whether to automatically install @types dependencies.
Alias for enableAutoTypes. Prefer the canonical setting name for new configurations.
# Example
tsEnableAutoTypes: true
Array of git repository URL patterns that are allowed to be fetched.
Git dependencies are rejected unless their repository URL matches one of these glob patterns. The default empty list blocks all git dependencies.
# Allow every repository from one GitHub organization.
approvedGitRepositories:
- "https://github.com/yarnpkg/*"
# Allow a single SSH repository.
approvedGitRepositories:
- "git@github.com:my-company/internal-package.git"
Maximum number of output lines kept in memory per daemon task.
Long-running daemon tasks keep a bounded output buffer so recent logs remain available without unbounded memory growth.
# Keep only a short tail for very chatty tasks.
daemonOutputBufferMaxLines: 200
# Keep a larger in-memory history while debugging task output.
daemonOutputBufferMaxLines: 5000
Maximum number of completed daemon tasks kept in memory.
Once this limit is reached, older completed or failed daemon tasks may be discarded from the daemon's in-memory history.
# Keep a smaller history on memory-constrained machines.
daemonMaxClosedTasks: 25
# Keep more completed tasks available for inspection.
daemonMaxClosedTasks: 250
Default warm-up period for long-lived daemon tasks.
After a long-lived task starts, dependents are unblocked once this duration elapses. Values without unit are in seconds.
# Use a shorter warm-up for tasks that become ready quickly.
daemonDefaultWarmupPeriod: "500ms"
# Use a longer warm-up for services that take time to become ready.
daemonDefaultWarmupPeriod: "10s"
Maximum number of task processes running at the same time.
The daemon shares this limit between all the yarn tasks run invocations it serves. Long-lived tasks and tasks without a script don't count toward it, nor do tasks waiting on a nested yarn tasks run. The background daemon reads it when it starts, so it must be restarted for changes to apply. Defaults to the number of CPUs.
# Run tasks one at a time.
taskConcurrency: 1
# Leave some CPUs available for other work.
taskConcurrency: 4
Define whether Yarn should automatically add @types packages.
When enabled, Yarn may add matching @types/* packages when adding dependencies that don't ship their own TypeScript declarations, and yarn remove also removes the @types/* package matching each removed dependency. Enabled by default when a tsconfig.json exists at the project root or in the active workspace. This setting is also available through the tsEnableAutoTypes alias.
# Enable automatic type acquisition explicitly.
enableAutoTypes: true
# Disable automatic type acquisition for projects that manage types manually.
enableAutoTypes: false
Define whether the cache clean command is allowed to remove cache entries.
If false, yarn cache clean refuses to run and reports an error instead of removing entries from the cache.
# Prevent cache clean operations in shared environments.
enableCacheClean: false
# Allow cache clean operations.
enableCacheClean: true
Define whether unused packages should be removed from the local cache after installs.
When enabled, Yarn removes the archives that the project doesn't use anymore from the project-local cache after each install. This only applies when enableGlobalCache is disabled and cacheFolder is left to its default: a custom cache folder may be shared with other projects, so it is never pruned. Unused entries make installs fail when enableImmutableCache is set, unless this setting is disabled.
# Keep the root node_modules folder when installing with the pnp linker.
enableLocalCacheCleanup: false
Define whether migration mode should be enabled.
Migration mode changes various settings to make migration easier. It is usually applied automatically by Yarn Switch when necessary rather than set manually.
# Enable migration compatibility behavior for a project.
enableMigrationMode: true
# Use the regular behavior once migration is complete.
enableMigrationMode: false
Define whether Yarn should enforce unsafe HTTP requests over HTTPS.
If true, Yarn rewrites the URL of every request to use plain http: instead of https:, and unsafeHttpWhitelist isn't checked anymore. This setting is intended for controlled environments (such as tests against a local registry) that deliberately need to force unsafe HTTP behavior.
# Keep HTTPS enforcement enabled.
enforceUnsafeHttp: false
# Force unsafe HTTP in a controlled test environment.
enforceUnsafeHttp: true
URL used to download Node.js distributions.
Yarn reads the list of releases (index.json) and downloads the Node.js binaries from this endpoint when resolving builtin: Node.js dependencies (for example @yarnpkg/node: builtin:^22.0.0). The builds for musl-based systems come from nodeUnofficialDistUrl.
# Use the official Node.js distribution endpoint.
nodeDistUrl: "https://nodejs.org/dist"
# Use an internal mirror for Node.js distributions.
nodeDistUrl: "https://artifacts.example.com/nodejs/dist"
URL used to download the unofficial Node.js builds.
The official Node.js builds for Linux require glibc, so on musl-based systems such as Alpine Yarn installs the musl builds the Node.js project publishes as unofficial builds. Those systems read the list of releases (index.json) and download their Node.js binaries from this endpoint, which is expected to follow the layout of the Node.js project's unofficial builds.
# Use an internal mirror for the unofficial Node.js builds.
nodeUnofficialDistUrl: "https://artifacts.example.com/nodejs/unofficial-builds"
Minimum package version age required before installation.
Versions newer than this duration won't be considered for installation unless they are preapproved. This can reduce exposure to newly-published supply-chain incidents.
When every version matching a request is too recent, the resolution fails with an error that names the newest of them and the date it was published, rather than reporting that nothing matched.
The duration accepts the ms, s, m, h, d, and w units; values without unit are in minutes (as in Yarn 4), so 1440 is one day; 0 disables the gate. The value can be overridden per scope (npmScopes), per registry (sourceRules), and per package (packageRules), in increasing order of precedence; --no-time-gate on yarn add and yarn up disables all of them.
# Require packages to be at least one day old.
npmMinimalAgeGate: "1d"
# Use a shorter gate for fast-moving internal projects.
npmMinimalAgeGate: "1h"
Package descriptors that bypass the minimum age gate.
Use this list for packages you trust or that must be installed immediately despite npmMinimalAgeGate.
# Preapprove one package range.
npmPreapprovedPackages:
- "typescript@^5.0.0"
# Preapprove multiple trusted packages.
npmPreapprovedPackages:
- "@my-scope/*@*"
- "eslint@^9.0.0"
Package patterns hoisted to node_modules/.yarn/store/node_modules.
By default all packages are hoisted into the hidden modules directory inside the pnpm virtual store. Use an empty array to disable this hoisting.
# Disable hidden-store hoisting.
pnpmHoistPatterns: []
# Hoist every package plus a scoped package family.
pnpmHoistPatterns:
- "*"
- "@babel/*"
Package patterns hoisted to the root node_modules directory.
Unlike pnpmHoistPatterns, this setting hoists matching packages to the public root node_modules directory.
# Expose selected tooling packages at the project root.
pnpmPublicHoistPatterns:
- "eslint"
- "prettier"
# Disable public hoisting.
pnpmPublicHoistPatterns: []
Timeout before a network request is considered slow.
Controls when Yarn reports a network request as slow. Values without unit are in milliseconds.
# Report slow requests after five seconds.
slowNetworkTimeout: "5s"
# Use a more patient threshold on slow networks.
slowNetworkTimeout: "30s"
Configuration of resolution islands.
Each island resolves its transitive dependencies in isolation using a constraint solver, producing at most one version of each package per island. Each entry accepts:
workspaces: the workspace name glob patterns belonging to the island.linker:node-modules, orvenvfor Python workspaces using thepypi:protocol.pythonVersion: the Python version of the island, overriding the.python-versionfiles (the island's and the project's) and the globalpythonVersionsetting.pypiConstraints: PEP 508 requirements restricting the versions the island may select, without adding the packages to the island (like uv'sconstraint-dependencies).pypiSeedLockfile: the path (relative to the project root) of auv.lockfile whose versions are preferred while the island has no entry in the lockfile yet;yarn import uvsets it so that migrating doesn't upgrade anything.
# Resolve a subset of workspaces through the node-modules linker.
unstableIslands:
web:
workspaces:
- "@acme/web-*"
linker: "node-modules"
# Resolve Python workspaces through the venv linker.
unstableIslands:
python:
workspaces:
- "@acme/py-*"
linker: "venv"
pythonVersion: "3.13"
pypiConstraints:
- "protobuf<6"
Per-profile dependencies that can be applied to workspaces.
Workspace profiles let you define reusable dev dependency sets. Workspaces can inherit them through their manifest extends field, and the default profile is applied automatically. Each profile accepts devDependencies, which are added to the workspace unless it already declares them, and extends, a list of other profiles to apply as well. When several profiles define the same dependency, the profiles the workspace lists win over the profiles those extend, a profile wins over the ones listed before it, and the default profile comes last.
# Apply a managed Node.js version to every workspace.
workspaceProfiles:
default:
devDependencies:
"@yarnpkg/node": "builtin:^22.0.0"
# Compose a web profile from a shared tooling profile.
workspaceProfiles:
tooling:
devDependencies:
typescript: "^5.0.0"
web:
extends:
- "tooling"
devDependencies:
vite: "^6.0.0"
Version range required for the Yarn Switch binary.
When set, Yarn validates that the Yarn Switch binary version satisfies this semver range before executing any command.
# Require Yarn Switch 6 or newer.
switchVersionRequirement: "^6.0.0"
# Disable the Switch version requirement.
switchVersionRequirement: null
Default dependency catalog.
Maps package names to version ranges. This is an alias for catalogs.default, and entries can be referenced through the catalog: protocol.
# Define shared ranges for common dependencies.
catalog:
react: "^19.0.0"
typescript: "^5.0.0"
# Define scoped package ranges.
catalog:
"@types/node": "^22.0.0"
Named dependency catalogs.
Named catalogs contain predefined version ranges for packages. Use catalog:name in dependencies to reference a named catalog.
# Define separate catalogs for app and tooling dependencies.
catalogs:
react19:
react: "^19.0.0"
react-dom: "^19.0.0"
tooling:
typescript: "^5.0.0"
# Define an empty named catalog to fill in later.
catalogs:
future: {}
Array of hostname glob patterns for which using the HTTP protocol is allowed.
Requests to http: URLs are rejected unless their hostname matches one of these patterns (or enforceUnsafeHttp is enabled).
# Allow HTTP for a single internal host.
unsafeHttpWhitelist:
- "registry.internal.example"
# Allow HTTP for a whole internal domain.
unsafeHttpWhitelist:
- "*.corp.example"
Path where virtual packages will be stored.
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__.
# Example
virtualFolder: ".cache/__virtual__"