19

We're in the process of migrating our monorepo to use Lerna.

Lerna supports both NPM and Yarn and furthermore allows configuration of use with Yarn workspaces. It's unclear to me whether Lerna with Yarn workspaces has any distinct advantages to Lerna with NPM. Many posts claim that Lerna does more or less the same thing as Yarn workspaces out of the box.

Are there any advantages to using Lerna with Yarn workspaces opposed to Lerna with NPM?

1
  • do you need any more help with this question? Please let me know or mark my answer as accepted. Thank you.
    – Peter
    Commented Jul 19, 2019 at 15:37

2 Answers 2

9

As far as I know, NPM doesn't have any mechanism comparable to Yarn workspaces.

Lerna + Yarn workspaces begins to shine when developing a library, as opposed to an application, however, I find that even with an application, this combination can make the local developer experience better by providing conveniences such as release management and the ability to easily define and run 'root' scripts across all or a select 'scope' of packages in the project.

2
  • 1
    Thanks for your answer! Is there anything Lerna can't do with NPM that it can do with Yarn workspaces? Or is one system superior to the other in terms of speed, stability, ect?
    – axelyung
    Commented Sep 6, 2018 at 16:33
  • 2
    @axelyung I rarely use NPM and don't have a reliable answer to the first part of your question. Regarding your second question, I find yarn to be much faster than npm.
    – Peter
    Commented Sep 6, 2018 at 18:54
7

After some investigation, I've found the following differences:

  1. Using NPM results in a package-lock.json file for each package where using Yarn only creates one in the root of the project.
  2. Yarn workspaces seems to have better support for resolving possible conflicts in the dependency tree (given that dependencies are declared in the module where they are used, see this issue)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.