lerna: Lerna does not support yarn 2 workspace:* url type

Lerna does not seem to support the new workspace:* version schema used in yarn2. This seems really strange to me given that the yarn documentation mentions Lerna immediately after the section in the documentation on workspace:* so I may be missing something here.

Expected Behavior

I would expect Lerna to understand this dependency format and resolve to the local workspace copy of the package.

Current Behavior

Lerna: ERR! Error: unsupported url type “workspace:”: “workspace:*”

Steps to Reproduce (for bugs)

Create a simple repo using yarn 2 with packages a and b

Run

yarn workspace a add b@workspace:*

Run lerna version

Your Environment

Executable Version
lerna --version 3.20.2
yarn --version 2.0.0-rc.33
node --version 12.16.1
OS Version
NAME VERSION
Windows 10 17763

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 45
  • Comments: 17 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Waiting for this feature too 👍

Until this issue is resolved, would it make sense to remove this text from https://yarnpkg.com/features/workspaces#yarn-workspaces-vs-lerna? It is so far as I can tell factually incorrect.

If there is some sense in which it is correct, maybe there is some improvement to the wording that doesn’t have the same risk of misleading users into thinking some things will work that don’t.

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.

I’m having the same issue. I’m using pnpm and my lerna publish ... is failing due to an “unrecognised dependency URL workspace:*”.

It’s actively being worked on as we speak, and will complement similar updates for pnpm support in #3284

Now that Lerna is taken over by Nx, will this get fixed in the forseeable future?

@weiwei @harrytran998 and everyone else… As a possible alternative, you can use Lerna-Lite, that I forked before Nrwl came in, the commands are the same and I added support for workspace: protocol for well over 2 months now, I also migrated the project itself to pnpm (it works with yarn too) and I also use the workspace: protocol within the project, it makes it easier to test the code and to make sure everything is running as expected… there are a few large projects that are already using this feature. I also keep PRs in sync with Lerna so it doesn’t fall behind.

I’m sure that Lerna will eventually bring the feature but for now Lerna-Lite is a good alternative and it works pretty well with the workspace: protocol

Cheers and happy coding

Any workaround for this? Kinda surprising that this hasn’t been looked at given the amount of users of both projects 😕

Hi Folks, I’m going to close this one as lerna fully supports the workspace: specifier for yarn 1, yarn 2+ (using the node_modules linker) and pnpm.

If you run into any issues please feel free to open a new issue with as much context as possible.

Many thanks!

pnpm update will also set the version range string to use workspace:, which will make subsequent calls to lerna fail. @suedama1756 maybe you can update the title to include pnpm so it’s clear that this issue is not limited to yarn?

@rhyek a workaround is to replace the build command in package.json with

package.json

   "build": "yarn workspaces foreach run build"
   ...

instead of lerna run build so lerna won’t complaint about the yarn 2 workspace:* url type

e.g. ui: workspace:packages/ui

@rhyek babel used to have some patches related to this if (ex. https://github.com/eankeen/babel/tree/72712f236b52ae8db27e03a08a59ced08b23efef/.yarn-patches/%40lerna). what i did is use some of those patches, change them a bit to work with patch-package, and do that. unfortunately, i don’t have those modified patches as of now, but everything worked fine back then