网页 综合 更新时间 2026-11-14 16:25:19

Settings (.yarnrc.yml) | Yarn

自动蜘蛛 yarnpkg.com 正文约 5041 字
Settings (.yarnrc.yml) | Yarn
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 variable expansion is available in the following forms:
$, \, and } can be escaped by preceding them with a \. All other \s and unmatched } are treated literally. Unclosed expansions and unescaped ${ sequences that are not recognized as an expansion throw errors.
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.
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.
Behavior that Yarn should follow when it detects that a cache entry is outdated.
Whether or not a cache entry is outdated depends on whether it has been built and checksumed by an earlier release of Yarn, or under a different compression settings. Possible behaviors are:
The default catalog of packages.
Named catalogs of packages.
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 master, origin/master, upstream/master, main, origin/main, and upstream/main.
Array of file glob patterns that will be excluded from change detection.
Files matching the following patterns (in terms of relative paths compared to the root of the project) will be ignored by every command checking whether files changed compared to the base ref (this include both yarn version check and yarn workspaces foreach --since).
Behavior that Yarn should follow when it detects that a cache entry has a different checksum than expected.
Possible behaviors are:
Amount of git clone operations that Yarn will run at the same time.
We by default limit it to 2 concurrent clone operations.
Array of git repository URL glob patterns that are allowed to be fetched.
When set, Yarn will block any git dependency whose normalized repository URL doesn't match one of these patterns. GitHub repositories must be explicitly approved.
Compression level employed for zip archives
Possible values go from 0 ("no compression, faster") to 9 ("heavy compression, slower"). The value mixed is a variant of 9 where files are stored uncompressed if the gzip overhead would exceed the size gain.
The default is 0, which tends to be significantly faster to install. Projects using zero-installs are advised to keep it this way, as experiments showed that Git stores uncompressed package archives more efficiently than gzip-compressed ones.
Path of the constraints file.
This only matters for Prolog constraints, which are being deprecated. JavaScript constraints will always be read from the yarn.config.cjs file.
Default language mode that should be used when a package doesn't offer any insight.
This is an internal configuration setting that shouldn't be touched unless you really know what you're doing.
Default protocol that should be used when a dependency range is a pure semver range.
This is an internal configuration setting that shouldn't be touched unless you really know what you're doing.
Default prefix used in semver ranges created by yarn add and similar commands.
Possible values are "^" (the default), "~" or "".
Folder where the versioning files are stored.
Define whether colors are allowed on the standard output.
The default is to check the terminal capabilities, but you can manually override it to either true or false.
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.
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 will query the remote registries to validate that the lockfile content matches the remote information. These checks make installs slower, so you should only run them on branches managed by users outside your circle of trust.
访问原文 返回搜索 https://yarnpkg.com/configuration/yarnrc
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。