reopen bootstrap removes node_modules from root (during hoist)
See original GitHub issueHi, this is a vote to repopen https://github.com/lerna/lerna/issues/889#issue-237423886 which was closed due to inactivity.
Can you provide an example repo? I’m a bit mystified by the context of this error. (https://github.com/lerna/lerna/issues/889#issuecomment-312334120)
Say we have a lerna repo which contains of two packages “p1” and “p2”:
{
"name": "p1",
"dependencies": {
"lodash": "latest"
}
}
and
{
"name": "p2",
"dependencies": {
"underscore": "latest"
}
}
and now one executes:
lerna bootstrap --hoist --include-dependencies --scope p1
…then lodash
is hoisted to the root’s node_modules
,
Now one executes:
lerna bootstrap --hoist --include-dependencies --scope p2
…then lodash
disappears from the root’s node_modules
and instead underscore
is hoisted.
It would be great if this could be controlled via a flag, e.g. --keep-existing-node-modules
.
It is often desired to keep already existing node_modules in the root when working on several projects at the same time and it is annoying if one project removes the deps of another project.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top GitHub Comments
Thanks for the answer. Our monorepo hosts multiple independent frontend components in separate packages (but with shared dependencies). So our main use case is bootstrapping some packages, but not all of them. My understanding is that if we were to switch to yarn or pnpm workspaces, we could only bootstrap the entire monorepo all at once, which is something we want to avoid. But do correct me if I’m wrong. Also, for dependencies within the monorepo, we need to be able to tell what version of another package our package depends on. We lose that information with relative file
file:
specifiers.lerna bootstrap --hoist
is a brilliant, complicated hack that was necessary when it was written (almost) four years ago. It is now no longer necessary because package managers have either implemented workspaces or plan to in near future (with acceptable workarounds in the meantime). You should use these alternatives instead oflerna bootstrap
:file:
specifiersnpx lerna link convert
will set this up, this is how Lerna’s own monorepo works