yarn install — Yarn CLI reference

Install dependencies

Docs/Reference/CLI/install

yarn install

Install dependencies

yarn install

This command resolves, fetches, links, and builds the dependencies for the current project.

  • Resolution: Yarn selects concrete package versions that satisfy the dependency ranges declared by your workspaces.

  • Fetch: Yarn downloads missing packages and stores them in the cache configured by cacheFolder.

  • Link: Yarn writes the dependency tree to disk using the configured linker, such as Plug’n’Play or node_modules.

  • Build: Yarn runs required build scripts in dependency order, subject to enableScripts and package trust rules.

Projects using zero-installs may not need to run this command after every clone or branch switch, provided the cache and install artifacts are checked into the repository.

If --immutable is set, Yarn aborts if the lockfile or any configured immutable pattern would be modified. --frozen-lockfile is accepted as an alias for compatibility.

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 --refresh-lockfile is set, Yarn keeps the same resolutions but refreshes their metadata. Combined with --immutable, it validates that the lockfile metadata is still consistent. Hardened mode enables this behavior automatically in public pull-request contexts.

If --check-cache is set, Yarn refetches packages and verifies that the remote checksum matches both the lockfile and any existing cache entry. This is useful for zero-install projects that accept third-party pull requests.

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:

  • skip-build will not run the build scripts at all. Note that this is different from setting enableScripts to false because the latter will disable build scripts, and thus affect the content of the artifacts generated on disk, whereas the former will just disable the build step - but not the scripts themselves, which just won’t run.

  • update-lockfile will skip the link step altogether, and only fetch packages that are missing from the lockfile (or that have no associated checksums). This mode is typically used by tools like Renovate or Dependabot to keep a lockfile up-to-date without incurring the full install cost.

#--check-resolutionsboolean

Validate that lockfile resolutions are coherent

#--frozen-lockfile, --immutableboolean

Abort if the lockfile or immutable patterns would be modified

#--immutable-cacheboolean

Abort if the cache folder would be modified

#--check-checksums, --check-cacheboolean

Refetch packages and verify their checksums against the lockfile and cache

#--refresh-lockfileboolean

Refresh package metadata stored in the lockfile

#--modeboolean

Select which install artifacts Yarn should generate

#--silentboolean

Hide any output but errors

#--inline-buildsboolean

Verbosely print the output of the build steps of your dependencies

#--jsonboolean

Format the output as an NDJSON stream