You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

policies.md 2.1 kB

3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ---
  2. id: docs_cli_policies
  3. guide: docs_cli
  4. layout: guide
  5. ---
  6. {% include vars.html %}
  7. <p class="lead">Defines project-wide policies for your project.</p>
  8. ### Enforcing Yarn's version across your project <a class="toc" id="toc-policies-set-version" href="#toc-policies-set-version"></a>
  9. When working inside a team, you usually end up in the situation where one of your
  10. colleagues uses a different version of Yarn than you. While usually inconsequential,
  11. it might sometimes cause subtle and hard to debug issues - for example your colleague
  12. might be on a version of Yarn that doesn't support a feature you rely on, such as
  13. the workspaces.
  14. In order to alleviate this issue, you can specify the required Yarn version inside
  15. the `package.json` file, which will prompt your colleagues to use the same version as
  16. you. Unfortunately, while technically strong, this technique adds an unwanted burden
  17. on them - given that the Yarn binary is typically global, switching from a branch to
  18. another might be particularly annoying if they change the version.
  19. To fix that, `yarn policies set-version` offers a simple way to **check in your Yarn
  20. release within your repository.** Once you run it, your configuration will be updated
  21. in such a way that anyone running a Yarn command inside the project will always use
  22. the version you set - and this transparently.
  23. The command accepts various ways to set which version you want to use:
  24. - `yarn policies set-version` will download the latest stable release
  25. - `yarn policies set-version --rc` will download the latest rc release
  26. - `yarn policies set-version 1.13.0` will download a specific version
  27. - `yarn policies set-version '^1.12.0'` will download the latest minor
  28. Under the hood, the command will simply download the single-file release from the
  29. GitHub repository, store it inside your project (inside the `.yarn/releases` folder),
  30. then finally update your configuration to point to the new file (using `yarn-path`).
  31. Note that this command also is the preferred way to upgrade Yarn - it will work no
  32. matter how you originally installed it, which might sometimes prove difficult to
  33. figure out otherwise.

js yarn包管理组件依赖分析

Contributors (1)