|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- ---
- id: docs_cli_install
- guide: docs_cli
- layout: guide
- ---
-
- {% include vars.html %}
-
- `yarn install` is used to install all dependencies for a project. This is most
- commonly used when you have just checked out code for a project, or when
- another developer on the project has added a new dependency that you need to
- pick up.
-
- If you are used to using npm you might be expecting to use `--save` or
- `--save-dev`. These have been replaced by `yarn add` and `yarn add --dev`. For
- more information, see
- [the `yarn add` documentation]({{url_base}}/docs/cli/add).
-
- Running `yarn` with no command will run `yarn install`, passing through any provided flags.
-
- If you need reproducible dependencies, which is usually the case with the continuous integration systems, you should pass `--frozen-lockfile` flag.
-
- ##### `yarn install` <a class="toc" id="toc-yarn-install" href="#toc-yarn-install"></a>
-
- Install all the dependencies listed within `package.json` in the local
- `node_modules` folder.
-
- The `yarn.lock` file is utilized as follows:
-
- - If `yarn.lock` is present and is enough to satisfy all the dependencies listed in `package.json`, the exact versions recorded in `yarn.lock` are installed, and `yarn.lock` will be unchanged. Yarn will not check for newer versions.
- - If `yarn.lock` is absent, or is _not_ enough to satisfy all the dependencies listed in `package.json` (for example, if you manually add a dependency to `package.json`), Yarn looks for the newest versions available that satisfy the constraints in `package.json`. The results are written to `yarn.lock`.
-
- If you want to ensure `yarn.lock` is not updated, use `--frozen-lockfile`.
-
- ##### `yarn install --check-files` <a class="toc" id="toc-yarn-install-check-files" href="#toc-yarn-install-check-files"></a>
-
- Verifies that already installed files in `node_modules` did not get removed.
-
- ##### `yarn install --flat` <a class="toc" id="toc-yarn-install-flat" href="#toc-yarn-install-flat"></a>
-
- Install all the dependencies, but only allow one version for each package. On the first run this will prompt you to
- choose a single version for each package that is depended on at multiple
- version ranges. These will be added to your `package.json` under a
- `resolutions` field.
-
- ```json
- "resolutions": {
- "package-a": "2.0.0",
- "package-b": "5.0.0",
- "package-c": "1.5.2"
- }
- ```
-
- ##### `yarn install --force` <a class="toc" id="toc-yarn-install-force" href="#toc-yarn-install-force"></a>
-
- This refetches all packages, even ones that were previously installed.
-
- ##### `yarn install --har` <a class="toc" id="toc-yarn-install-har" href="#toc-yarn-install-har"></a>
-
- Outputs an [HTTP archive](https://en.wikipedia.org/wiki/.har) from all the
- network requests performed during the installation. HAR files are commonly used
- to investigate network performance, and can be analyzed with tools such as
- [Google's HAR Analyzer](https://toolbox.googleapps.com/apps/har_analyzer/) or
- [HAR Viewer](http://www.softwareishard.com/blog/har-viewer/).
-
- ##### `yarn install --ignore-scripts` <a class="toc" id="toc-yarn-install-ignore-scripts" href="#toc-yarn-install-ignore-scripts"></a>
-
- Do not execute any scripts defined in the project package.json and its dependencies.
-
- ##### `yarn install --modules-folder <path>` <a class="toc" id="toc-yarn-install-modules-folder" href="#toc-yarn-install-modules-folder"></a>
-
- Specifies an alternate location for the `node_modules` directory, instead of the default `./node_modules`.
-
- ##### `yarn install --no-lockfile` <a class="toc" id="toc-yarn-install-no-lockfile" href="#toc-yarn-install-no-lockfile"></a>
-
- Don't read or generate a `yarn.lock` lockfile.
-
- ##### `yarn install --production[=true|false]` <a class="toc" id="toc-yarn-install-production-true-false" href="#toc-yarn-install-production-true-false"></a>
-
- Yarn will not install any package listed in `devDependencies` if the `NODE_ENV` environment variable is set to `production`. Use this flag to instruct Yarn to ignore `NODE_ENV` and take its production-or-not status from this flag instead.
-
- > **Notes:** `--production` is the same as `--production=true`. `--prod` is an alias of `--production`.
-
- ##### `yarn install --pure-lockfile` <a class="toc" id="toc-yarn-install-pure-lockfile" href="#toc-yarn-install-pure-lockfile"></a>
-
- Don't generate a `yarn.lock` lockfile.
-
- ##### `yarn install --focus` <a class="toc" id="toc-yarn-install-focus" href="#toc-yarn-install-focus"></a>
-
- Shallowly installs a package's sibling workspace dependencies underneath its `node_modules` folder. This allows you to run that workspace without building the other workspaces it depends on.
-
- Must be run inside an individual workspace in a workspaces project. Can not be run in a non-workspaces project or at the root of a workspaces project.
-
- [Learn more about focused workspaces.](https://yarnpkg.com/blog/2018/05/18/focused-workspaces/)
-
- ##### `yarn install --frozen-lockfile` <a class="toc" id="toc-yarn-install-frozen-lockfile" href="#toc-yarn-install-frozen-lockfile"></a>
-
- Don't generate a `yarn.lock` lockfile and fail if an update is needed.
-
- ##### `yarn install --silent` <a class="toc" id="toc-yarn-install-silent" href="#toc-yarn-install-silent"></a>
-
- Run yarn install without printing installation log.
-
- ##### `yarn install --ignore-engines` <a class="toc" id="toc-yarn-install-ignore-engines" href="#toc-yarn-install-ignore-engines"></a>
-
- Ignore engines check.
-
- ##### `yarn install --ignore-optional` <a class="toc" id="toc-yarn-install-ignore-optional" href="#toc-yarn-install-ignore-optional"></a>
-
- Don't install optional dependencies.
-
- ##### `yarn install --offline` <a class="toc" id="toc-yarn-install-offline" href="#toc-yarn-install-offline"></a>
-
- Run yarn install in offline mode.
-
- ##### `yarn install --non-interactive` <a class="toc" id="toc-yarn-install-non-interactive" href="#toc-yarn-install-non-interactive"></a>
-
- Disable interactive prompts, like when there's an invalid version of a dependency.
-
- ##### `yarn install --update-checksums` <a class="toc" id="toc-yarn-install-update-checksums" href="#toc-yarn-install-update-checksums"></a>
-
- Update checksums in the `yarn.lock` lockfile if there's a mismatch between them and their package's checksum.
-
- ##### `yarn install --audit` <a class="toc" id="toc-yarn-install-audit" href="#toc-yarn-install-audit"></a>
-
- Checks for known security issues with the installed packages. A count of found issues will be added to the output. Use the `yarn audit` command for additional details. Unlike npm, which automatically runs an audit on every install, yarn will only do so when requested. (This may change in a later update as the feature is proven to be stable.)
-
- ##### `yarn install --no-bin-links` <a class="toc" id="toc-yarn-install-no-bin-links" href="#toc-yarn-install-no-bin-links"></a>
-
- Prevent yarn from creating symlinks for any binaries the package might contain.
-
- ##### `yarn install --link-duplicates` <a class="toc" id="toc-yarn-install-link-duplicates" href="#toc-yarn-install-link-duplicates"></a>
-
- Create hardlinks to the repeated modules in node_modules.
-
- ##### `yarn install --verbose` <a class="toc" id="toc-yarn-install-verbose" href="#toc-yarn-install-verbose"></a>
-
- Show additional logs while installing dependencies
-
|