Lerna: Lerna hoists even non-shared dependencies

Created on 29 Apr 2019  Â·  3Comments  Â·  Source: lerna/lerna

Expected Behavior



Hoisting only hoists shared deps to root

Current Behavior



Hoisting hoists deps to root even if only used in one package

Possible Solution



Modify the docs to reflect that this is how it works.
https://github.com/lerna/lerna/blob/master/doc/hoist.md

Steps to Reproduce (for bugs)


  1. Pick any repo using lerna
  2. Do npx lerna bootstrap --hoist
  3. Note that npm packges only used in a single child package show up in the root node_modules

lerna.json


<!-- Please paste your `lerna.json` here -->
{
  "packages": [
    "packages/*"
  ],
  "version": "0.0.17"
}

Context



I wanted to understand what to cache in CI (in other words, where to expect to find most of the data in node_modules - the root or the child packages. The docs were misleading and made me think most of the content would be in the child package dirs.

Your Environment

| Executable | Version |
| ---: | :--- |
| lerna --version | 3.13.4 |
| npm --version | 6.9.0 |
| yarn --version | n/a |
| node --version | 10.15 |
-->

good first issue help wanted

Most helpful comment

Sure, that's a good change.

All 3 comments

Quoting from the current docs:

Lerna can reduce the time and space requirements for numerous copies of packages in development and build environments, by "hoisting" shared dependencies up to the topmost, Lerna-project-level node_modules directory instead.

Is that not clear?

npm packges only used in a single child package show up in the root node_modules

This is _exactly_ how it should work.

@evocateur Thanks for the explanation. Ah yeah, then it’s the docs that could be clearer. If we remove the word “shared” it would be clear. Because even those that aren’t shared by another package get hoisted.

Sure, that's a good change.

Was this page helpful?
0 / 5 - 0 ratings