Hoist may delete certain packages from the packages folder during bootstrap
See original GitHub issueToday I ran into one of the worst things a software can do because a bug: fail destructively.
I recently started to use hoist to save lot of startup time and space during development. However I find a situation where hoist behaves destructively, which should never happen in this kind of tool. Luckly git (specifically VSCode git interface) show me a bunch of deleted files in a bright red that took my attention. This may be the result of a mixture of uncommon variables:
- I wanted to hoist certain local packages, so I added the root of the repo to the packages array
- There is a mismatch on the package version and the packages that depend on it
Expected Behavior
I expected lerna to warn me some way, instead of deleting my package and fail with a long and unreadable stack trace
Current Behavior
The package is deleted and sometimes bootstrap fails, and other times it succeeds. Very erratic
Steps to Reproduce (for bugs)
- On a lerna repo in lerna.json add “.” to the array of packages
- Make one package with a version, let’s say 0.2.4
- Add one or two more packages depending on the first one but with a different version than the current one, fort example 0.2.2
- Add
hoist: true
to lerna.json or add the option during the bootstrap command - Execute lerna bootstrap
{
"lerna": "2.0.0",
"packages": [
".",
"src/*"
],
"hoist": true,
"registry": "https://tools.caseonit.com/npm",
"commands": {
"publish": {
"conventionalCommits": true,
"message": "chore: Publish"
}
},
"version": "independent"
}
lerna-debug.log
No lerna-debug is generated
Your Environment
Executable | Version |
---|---|
lerna --version |
2.0.0 |
npm --version |
4.1.2 |
node --version |
7.7.1 |
OS | Version |
---|---|
MacOSX | El Capitan |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:20
- Comments:41 (21 by maintainers)
Top Results From Across the Web
nohoist in Workspaces | Yarn Blog
With hoist, we were able to eliminate duplicate “A@1.0” and “B@1.0”, while preserving version variation (B@2.0) and maintaining the same root ...
Read more >Why can't I delete a package using NuGet? - Stack Overflow
3 Answers 3 · Right-click the references folder · Select 'manage nuget packages' · Select 'installed packages' · Select the package you want...
Read more >Untitled
Symlink together all Lerna `packages` that are dependencies of each other. 3. `npm run prepublish` in all bootstrapped packages. 4. `npm run prepare`...
Read more >Starting with Monorepos using Lerna - Joel H. Gomez Paredes
In a Lerna Repository we have a package.json and a folder called packages, ... use is lerna bootstrap, this command install dependencies of...
Read more >JavaScript Monorepos - Scott Logic Blog
There is an option for Lerna called hoist e.g. lerna bootstrap --hoist . When that option is set all common dependencies, i.e. same...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
TL;DR: Don’t use
lerna bootstrap
. Yarn workspaces,pnpm recursive
, and npm workspaces (whenever they’re released, lol) should be more than sufficient.Similar to @daffl - we have a monorepo with 80+ packages. I major bumped one of the packages (let’s say
A
) from v1 to v2 locally (before it’s been deployed to be installed by).Two other packages (
B
andC
) depend on v1.x ofA
. So the root package structure might look likeWhen I run
lerna bootstrap --hoist
,A
is deleted:And B and C’s
package-lock.json
remains the same. I suspect becauseB
andC
’s dependence on v1 take precedence over the newly versioned v2.Has anyone experienced similar behavior to this?
Edit:
lerna run clean
may solve this issue.