yarn install | Yarn (original) (raw)

Install the project dependencies.

Usage

Examples

Install the project :


yarn install

Validate a project when using Zero-Installs :


yarn install --immutable --immutable-cache

Validate a project when using Zero-Installs (slightly safer if you accept external PRs) :


yarn install --immutable --immutable-cache --check-cache

Details

This command sets up your project if needed. The installation is split into four different steps that each have their own characteristics:

Note that running this command is not part of the recommended workflow. Yarn supports zero-installs, which means that as long as you store your cache and your .pnp.cjs file inside your repository, everything will work without requiring any install right after cloning your repository or switching branches.

If the --immutable option is set (defaults to true on CI), Yarn will abort with an error exit code if the lockfile was to be modified (other paths can be added using the [immutablePatterns](/configuration/yarnrc#immutablePatterns) configuration setting). For backward compatibility we offer an alias under the name of --frozen-lockfile, but it will be removed in a later release.

If the --immutable-cache option is set, Yarn will abort with an error exit code if the cache folder was to be modified (either because files would be added, or because they'd be removed).

If the --refresh-lockfile option is set, Yarn will keep the same resolution for the packages currently in the lockfile but will refresh their metadata. If used together with --immutable, it can validate that the lockfile information are consistent. This flag is enabled by default when Yarn detects it runs within a pull request context.

If the --check-cache option is set, Yarn will always refetch the packages and will ensure that their checksum matches what's 1/ described in the lockfile 2/ inside the existing cache files (if present). This is recommended as part of your CI workflow if you're both following the Zero-Installs model and accepting PRs from third-parties, as they'd otherwise have the ability to alter the checked-in packages before submitting them.

If the --inline-builds option is set, Yarn will verbosely print the output of the build steps of your dependencies (instead of writing them into individual files). This is likely useful mostly for debug purposes only when using Docker-like environments.

If the --mode=<mode> option is set, Yarn will change which artifacts are generated. The modes currently supported are:

Options

Definition Description
--json Format the output as an NDJSON stream
--immutable Abort with an error exit code if the lockfile was to be modified
--immutable-cache Abort with an error exit code if the cache folder was to be modified
--refresh-lockfile Refresh the package metadata stored in the lockfile
--check-cache Always refetch the packages and ensure that their checksums are consistent
--check-resolutions Validates that the package resolutions are coherent
--inline-builds Verbosely print the output of the build steps of dependencies
--mode #0 Change what artifacts installs generate