Using yarn and hoisting together causes yarn.lock to be ignored
See original GitHub issueIf you try to use --npm-client=yarn
and --hoist
simultaneously, all your package’s yarn.lock
files will be ignored because lerna
uses npm
instead of yarn
for everything except the top-level hoisted dependencies.
Expected Behavior
When using yarn
as the npm client, all installed dependencies should satisfy any yarn.lock
files that are present.
Current Behavior
lerna
invokes npm --global-style
instead of yarn
in each of the packages, causing the yarn.lock to be ignored.
Possible Solution
We could forbid the combination of hoisting and yarn, or at least warn that it will give surprising results.
A more complete solution would mangle the contents of yarn.lock in a way analogous to what lerna
already does for package.json
in order to preserve the intended semantics.
Steps to Reproduce (for bugs)
- In any lerna project, run
lerna bootstrap --hoist --npm-client=yarn
- Observe the resulting processes via
ps
orpstree
and see that lerna is runningnpm
instead ofyarn
.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
The Ultimate Guide to yarn.lock Lockfiles - Andrew Hansen
Every project using yarn should commit the yarn lockfile to source control. The lockfile is the source of truth for telling other developers ......
Read more >A guide to understanding how Yarn hoists dependencies and ...
Hoisting can conceal missing dependencies because hoisted dependencies can be imported anywhere in your project. If you forget to declare a ...
Read more >yarn.lock
During install, Yarn will only use the top-level yarn.lock file and will ignore any yarn.lock files that exist within dependencies. The top-level yarn.lock...
Read more >JavaScript package managers compared: npm, Yarn, or ...
With an install step, dependencies are stored in a file structure (e.g., within node_modules ) and a lock file is generated. This section...
Read more >Yarn Build - Babel-loader issues with Storybook
To fix the dependency tree, try following the steps below in the exact order: 1. Delete package-lock.json (not package.json!) and/or yarn.lock ...
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
Yarn will have a built in feature, called “workspaces” to offer a lerna like solution. More at https://github.com/yarnpkg/yarn/issues/3294
If
--hoist
needs to do a leaf install (i.e., there are “unhoisted”, possibly conflicting deps in the tree), then it will usenpm
becauseyarn
does not support--global-install
, which avoids leaking transitive dependencies incorrectly.