question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using yarn and hoisting together causes yarn.lock to be ignored

See original GitHub issue

If 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)

  1. In any lerna project, run lerna bootstrap --hoist --npm-client=yarn
  2. Observe the resulting processes via ps or pstree and see that lerna is running npm instead of yarn.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
MoOxcommented, Jun 10, 2017

Yarn will have a built in feature, called “workspaces” to offer a lerna like solution. More at https://github.com/yarnpkg/yarn/issues/3294

1reaction
evocateurcommented, Jun 20, 2017

If --hoist needs to do a leaf install (i.e., there are “unhoisted”, possibly conflicting deps in the tree), then it will use npm because yarn does not support --global-install, which avoids leaking transitive dependencies incorrectly.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found