Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Yarn 2 was released in Jan. What does it mean for Lerna future? #2449

Open
MirKml opened this issue Feb 13, 2020 · 37 comments
Open
Labels
scope: package management Issues with the bootstrap/add/link commands that relate to package management

Comments

@MirKml
Copy link

MirKml commented Feb 13, 2020

Yarn 2 aka berry stable version was released in January 2020.
Yarn 1 will be in maintenance mode only.
Yarn 2 is rewritten from scratch and has extended support for workspaces, its plugin architecture has benefits for tools such lerna.
There is good summary of yarn 2 features in article by one of the yarn authors. Lerna is mentioned more times.

Do you have any plans with lerna related to new yarn? Maybe some yarn 2 plugin? Maybe as another project? Will be yarn 2 supported with lerna?

@MirKml MirKml changed the title [Question] Yarn 2 was released in Jan. What it means for Lerna future? [Question] Yarn 2 was released in Jan. What does it mean for Lerna future? Feb 13, 2020
@smithcommajoseph
Copy link

smithcommajoseph commented May 19, 2020

Having 3 months pass without any response to this very reasonable inquiry does not instill much confidence. Are there any updates on this? Even a high level sentence or two would be useful for project planning.

@TakenPilot
Copy link

Could you be more specific with your question?

@bhovhannes
Copy link

lerna bootstrap does not currently work with Yarn 2. I am getting the following error:

lerna notice cli v3.22.1
lerna info versioning independent
lerna info ci enabled
lerna info bootstrap root only
Unknown Syntax Error: Unsupported option name ("--mutex").
$ yarn install [--json] [--immutable] [--immutable-cache] [--check-cache] [--inline-builds]
lerna ERR! yarn install --mutex network:42424 --non-interactive exited 1 in 'localize-monorepo'

--mutex option does not exist in Yarn 2 and Lerna does everything to pass that option to Yarn during bootstrap command.

These lines in @lerna/bootstrap:

       if (npmClient === "yarn" && !mutex) {
        return getPort({ port: 42424, host: "0.0.0.0" }).then(port => {
          this.npmConfig.mutex = `network:${port}`;
          this.logger.silly("npmConfig", this.npmConfig);
        });
      }

and these lines in @lerna/npm-install:

  if (cmd === "yarn" && mutex) {
    args.push("--mutex", mutex);
  }

@dbrockman
Copy link

Is it the goal of the Lerna project to be compatible with Yarn v2?
It's OK if that's out of scope for Lerna but it would be nice to know. Maybe write something in the readme.

@flybayer
Copy link

I'm planning to try https://rushstack.io instead of Lerna and yarn workspaces.

@goldo
Copy link

goldo commented Nov 23, 2020

Having the same yarn 2 compatibility problem with lerna.

@flybayer is rushstack worh it ?

@flybayer
Copy link

@goldo haven't been able to try it yet

@Kizmar
Copy link

Kizmar commented Dec 4, 2020

For what it's worth - I ended up doing the following to get around this issue:

  • Install Yarn Classic: yarn set version classic
  • Bootstrap packages: lerna bootstrap
  • Install Yarn 2 again: yarn set version berry

That allows me to continue using Yarn 2 with Lerna in this monorepo. I'm assuming if I were to add a new package and needed it linked, I'd have to downgrade to Yarn Classic again to bootstrap. For now, this works.

[Edit] Had to bail on this. Various things still weren't working when you have a CRA and packages in the same monorepo. We still have everything in one repo, but the CRA apps and the packages are treated as separate Yarn/Lerna projects. The "npm-feed" project uses Lerna to build and publish. The CRA apps reference packages published to our private npm feed.

@jmitchell38488
Copy link

Surprisingly and somewhat disappointing that well over a year after Yarn2 was released, Lerna still doesn't support it. In a project I'm working on, I want to leverage the enhanced working environment and overall speed that Yarn2 offers, especially it's support for workspaces and plugins.

Unfortunately I don't have a choice in leaning away from Lerna.

@iamrommel
Copy link

Agree, I'm moving away from lerna. unlerna for me!

@trivikr
Copy link

trivikr commented Mar 23, 2021

Unfortunately I don't have a choice in leaning away from Lerna.
Agree, I'm moving away from lerna. unlerna for me!

@jmitchell38488 @iamrommel What are the lerna alternatives that you explored?
In another GitHub issue, yarn2+changesets was suggested as an option #2703 (comment)

@christophehurpeau
Copy link

I use lerna with yarn 2 and it works perfectly with workspaces, just don't use bootstrap. What's not working for you ? lerna is still usefull for versionning and lerna exec/run, I found yarn workspaces foreach slow compared to lerna.

@trivikr
Copy link

trivikr commented Mar 24, 2021

What's not working for you?

The lerna 3.x is working fine for me right now. I'm preemptively exploring moving away from lerna for my monorepo setup for concerns largely around lack of maintenance raised in #2703

For example, GitHub shows security advisory for ssri dependency of lerna for 3.x which is reported in GitHub issue #2856
Looking at the current state of maintenance of lerna, the ssri dependency is not likely to get updated in 3.x with recommendation to upgrade to lerna 4.x instead.

Although lerna 4.x was released as response to #2703 (comment), the issues reported on 4.x are not triaged or responded to by maintainers (example #2841). Also, as per the download counts of lerna npm package, lerna 3.x is still downloaded three times that of lerna 4.x.

@iamrommel
Copy link

iamrommel commented Mar 24, 2021

@trivik
i was looking for bit.dev,
https://docs.bit.dev/docs/installation

Unfortunately I don't have a choice in leaning away from Lerna.
Agree, I'm moving away from lerna. unlerna for me!

@jmitchell38488 @iamrommel What are the lerna alternatives that you explored?
In another GitHub issue, yarn2+changesets was suggested as an option #2703 (comment)

@trivikr
Copy link

trivikr commented Jul 26, 2021

Update: yarn 3 was released today.

@JulienKode
Copy link

JulienKode commented Jul 31, 2021

Didn't succeed to have the versioning of Lerna with yarn v2 on my side

@JulienKode
Copy link

JulienKode commented Aug 8, 2021

Which tools people use right now with yarn v3 inside a monorepo to bump automatically their version with conventional commits ?

@trivikr
Copy link

trivikr commented Aug 8, 2021

Which tools people use right now with yarn v3 inside a monorepo to bump automatically their version with conventional commits ?

Yarn (berry) with changesets seems to be the best choice as per the discussion in #2703 (comment)

@dudulasry
Copy link

Any news regarding the support for yarn 2/3? We started to use lerna at work and we prefer not to move to another tool.

@christophehurpeau
Copy link

@dudulasry I use lerna with yarn 3 and it works perfectly with workspaces, just don't use bootstrap :)

@khaledosman
Copy link

@dudulasry I use lerna with yarn 3 and it works perfectly with workspaces, just don't use bootstrap :)

then how do you handle shared packages in the monorepo?

@christophehurpeau
Copy link

@dudulasry I use lerna with yarn 3 and it works perfectly with workspaces, just don't use bootstrap :)

then how do you handle shared packages in the monorepo?

what do you mean ? You can check https://github.com/christophehurpeau/nightingale which is open source and might help, its currently using nodeLinker: node-modules but it was also working with pnp at some point

@khaledosman
Copy link

@dudulasry I use lerna with yarn 3 and it works perfectly with workspaces, just don't use bootstrap :)

then how do you handle shared packages in the monorepo?

what do you mean ? You can check https://github.com/christophehurpeau/nightingale which is open source and might help, its currently using nodeLinker: node-modules but it was also working with pnp at some point

right, in your case these are just separate projects that live in the same repo, but lets say for example you have a @nightingale/core or @nightingale/sdk where you want to have shared code between these projects, this is where lerna bootstrap helps to create the symlinks for these packages and install them without needing to rely on publishing them to some npm registry

@christophehurpeau
Copy link

@dudulasry I use lerna with yarn 3 and it works perfectly with workspaces, just don't use bootstrap :)

then how do you handle shared packages in the monorepo?

what do you mean ? You can check https://github.com/christophehurpeau/nightingale which is open source and might help, its currently using nodeLinker: node-modules but it was also working with pnp at some point

right, in your case these are just separate projects that live in the same repo, but lets say for example you have a @nightingale/core or @nightingale/sdk where you want to have shared code between these projects, this is where lerna bootstrap helps to create the symlinks for these packages and install them without needing to rely on publishing them to some npm registry

These are not separated packages, symlinks are created with yarn workspaces (for example, nightingale uses nightingale-logger)

@Jay-flow
Copy link

Jay-flow commented Dec 2, 2021

Is it correct that lerna doesn't support yarn2 yet? I'm curious about the current progress.

@ceefour
Copy link

ceefour commented Jan 12, 2022

@Jay-flow as of Jan 12, 2022, only lerna bootstrap doesn't work with yarn 2/3.

However, other parts of lerna (v4, that I use) work well.

As @christophehurpeau noted, it's basically yarn v2/v3 workspaces now, with lerna added on top.
Since yarn workspaces pretty much already does what lerna bootstrap meant to do.

@Jay-flow
Copy link

@Jay-flow as of Jan 12, 2022, only lerna bootstrap doesn't work with yarn 2/3.

However, other parts of lerna (v4, that I use) work well.

As @christophehurpeau noted, it's basically yarn v2/v3 workspaces now, with lerna added on top.
Since yarn workspaces pretty much already does what lerna bootstrap meant to do.

I see your point. Thank you :)

@johncmunson
Copy link

johncmunson commented Jan 21, 2022

I know this is slightly off-topic, but does anyone know if Lerna is compatible with NPM Workspaces?

I know that with yarn, you can set "useWorkspaces": true in lerna.json and Lerna will essentially delegate as much as it can to yarn, such as symlinking and whatnot.

However, I don't want to use Yarn because v1 is no longer maintained, and the community has not embraced v2/3, including Lerna. It's really a frustrating and sad state of affairs.

Am I the only one who thinks this way? It appears so because I can't find anything online that documents best practices for using Lerna with NPM Workspaces.

@ceefour
Copy link

ceefour commented Jan 22, 2022

@johncmunson I have been using Yarn v2/v3 and in cases where pnp breaks the project, I just use nodeLinker: node-modules and call it a day.

None of my projects now use yarn v1. Everything works great with yarn v3.

@hartherbert
Copy link

hartherbert commented Jan 23, 2022

@johncmunson I use NPM workspaces with lerna and it works great.
I let NPM do all the symlinking and stuff (no need for lerna bootstrap) and can still use lerna's features like lerna version.

@841660202
Copy link

👑 ~/Desktop/slate git:(main) $ lerna bootstrap
lerna notice cli v4.0.0
lerna info bootstrap root only
Unknown Syntax Error: Unsupported option name ("--mutex").

$ yarn install [--json] [--immutable] [--immutable-cache] [--check-cache] [--inline-builds] [--mode #0]
lerna ERR! yarn install --mutex network:42424 --non-interactive exited 1 in 'slate-packages'
lerna ERR! yarn install --mutex network:42424 --non-interactive exited 1 in 'slate-packages'
👑 ~/Desktop/slate git:(main) $ yarn --version
3.0.1
👑 ~/Desktop/slate git:(main) $ lerna --version
4.0.0
👑 ~/Desktop/slate git:(main) $

@JamesHenry JamesHenry added the scope: package management Issues with the bootstrap/add/link commands that relate to package management label Jun 14, 2022
@EWhite613
Copy link

Some news from nwrl #3140 (reply in thread)

@Jackman3005
Copy link

Hello, any fresh news on this? It's been > 6 months since NWRL took over and they mentioned support for Yarn Berry in the post. Is this work planned at this time?

@snebjorn
Copy link

snebjorn commented Mar 23, 2023

Hi, I can't seem to figure out if lerna support yarn 2+ / berry or not.

I have a package where I use the workspace ranges in a peer dependency. However in my published package the workspace:^ isn't replaced.

Lerna seems to have built-in support for the syntax though

const specMatch = resolved.workspaceSpec.match(/^workspace:([~^]?)(.*)/);

Not sure what is going on here...

Furthermore if lerna is using yarn publish or npm publish to publish then if a project is using yarn 2+ / berry then the correct command is yarn npm publish.

Using the correct command should take care of all above workspace stuff

Publishing workspaces
When a workspace is packed into an archive (whether it's through yarn pack or one of the publish commands like yarn npm publish), we dynamically replace any workspace: dependency

Anyone know why my workspace range for my peer dependency doesn't work?

{
  "peerDependencies": {
    "my-pkg": "workspace:^"
  }
}

NB. I'm using Yarn 3.5.0

@fahslaj
Copy link
Contributor

fahslaj commented Mar 23, 2023

Hi @snebjorn , Lerna does support Yarn berry with nodeLinker: "node-modules". Lerna does not update peer dependencies at all when publishing, which is why it will not replace the workspace prefix in your example. Lerna behaves this way for all package managers.

@snebjorn
Copy link

snebjorn commented Mar 23, 2023

NPM doesn't seem to support workspace ranges (workspace:*|^|~), or at least I couldn't find it in their docs.

Will Lerna v7 be using Yarn's features as a low-level layer instead of its own implementation when applicable?
Yarn at least claims that Lerna uses Yarns implementation.

Yarn Workspaces vs Lerna
Despite the appearances, the Yarn workspaces and Lerna don't compete. In fact, Lerna will use Yarn's workspaces if possible. In a sense, you can see Lerna as a high-level layer on top of the low-level Yarn implementation.

Or should I open a bug report on usage of workspace ranges in peer dependencies?

Opened issue

@njfamirm
Copy link

njfamirm commented Jul 25, 2023

what is current status?
I'm dont use lerna bootstrap

but when want to create new version with yarn lerna version get this error

λ yarn lerna version minor -y
lerna notice cli v7.1.4
lerna info current version 0.0.0
lerna WARN force-publish all packages
lerna info Assuming all packages changed

Changes:
 - @alwatr-community/telegram: 0.0.0 => 0.1.0
 - @alwatr-community/day-countdown-bot: 0.0.0 => 0.1.0 (private)

lerna info auto-confirmed
lerna info execute Skipping releases
lerna info getChangelogConfig Auto-prefixing conventional-changelog preset "angular"
lerna info getChangelogConfig Successfully resolved preset "conventional-changelog-angular"
file:///Users/me/repo/alwatr-community/node_modules/prettier/index.mjs:16967
        throw new UndefinedParserError(
              ^

UndefinedParserError: No parser could be inferred for file "/Users/me/repo/alwatr-community/yarn.lock".
    at normalizeFormatOptions (file:///Users/me/repo/alwatr-community/node_modules/prettier/index.mjs:16967:15)
    at formatWithCursor (file:///Users/me/repo/alwatr-community/node_modules/prettier/index.mjs:18588:52)
    at file:///Users/me/repo/alwatr-community/node_modules/prettier/index.mjs:21784:12
    at async Module.format2 (file:///Users/me/repo/alwatr-community/node_modules/prettier/index.mjs:21789:25)

Node.js v19.2.0

lerna version: 7.1.4
yarn version: 3.6.1

also I'm use nodeLinker: node-modules in .yarnrc.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: package management Issues with the bootstrap/add/link commands that relate to package management
Projects
None yet
Development

No branches or pull requests