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.

import.md 2.2 kB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ---
  2. id: docs_cli_import
  3. guide: docs_cli
  4. layout: guide
  5. ---
  6. {% include vars.html %}
  7. <p class="lead">Generates <code>yarn.lock</code> from an npm <code>package-lock.json</code> file in the
  8. same location or an existing npm-installed <code>node_modules</code> folder.</p>
  9. ##### `yarn import` <a class="toc" id="toc-yarn-import" href="#toc-yarn-import"></a>
  10. This command assists the migration of projects currently relying on `package-lock.json`,
  11. minimizing the differences between the lockfile and the existing dependency tree
  12. as best as it can.
  13. ### Motivation <a class="toc" id="toc-motivation" href="#toc-motivation"></a>
  14. Many projects currently use `package-lock.json` or check their `node_modules` into
  15. source control because they have fragile dependency trees. These projects can’t
  16. easily migrate to Yarn, because `yarn install` could produce a wildly different
  17. logical dependency tree. Not all trees can be represented by Yarn’s `yarn.lock`,
  18. and some valid trees will be automatically deduped upon install. These nuances
  19. and others present a significant barrier to manual migration.
  20. `yarn import` aims to alleviate this challenge by generating a `yarn.lock` file
  21. in one of two ways:
  22. 1. Using the dependency tree in an existing `package-lock.json` file created by
  23. `npm install`
  24. 2. If no such file exists, using the versions found inside `node_modules` according
  25. to normal `require.resolve()` resolution rules.
  26. In cases where the Yarn resolution mechanism can’t satisfy the existing dependency
  27. tree identically, alerts will be made so that you may manually review the changes.
  28. The existing `node_modules` tree will be checked for validity beforehand (if
  29. not importing from `package-lock.json`), and the resultant lockfile should be
  30. `yarn install`able without any surprises (failed compatibility, unresolvable
  31. dependencies, auto-dedupes, etc.)
  32. ```sh
  33. $ yarn import
  34. ```
  35. ```
  36. yarn import vx.x.x
  37. success Folder in sync.
  38. warning Using version "2.2.4" of "lru-cache" instead of "2.7.3" for "ngstorage > grunt > minimatch"
  39. warning Using version "2.0.6" of "readable-stream" instead of "2.2.9" for "ngstorage > karma > chokidar > readdirp"
  40. [...]
  41. success Saved lockfile.
  42. ✨ Done in 11.96s.
  43. ```

js yarn包管理组件依赖分析

Contributors (1)