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.

Upgrading version of package used on monorepo root

See original GitHub issue

Expected Behavior

Upgrade the package version like it happens if it is used inside another workspace package.

Current Behavior

Doesn’t do it.

Possible Solution

Don’t know.

Steps to Reproduce (for bugs)

Example: https://github.com/tunnckoCoreHQ/hela/blob/v3-next/package.json#L26 I’m using one of my monorepo packages as a dependency to the monorepo root. Usually when new release is done, Lerna updates the package version if this package is used inside other monorepo packages. But Lerna doesn’t update its version if it is in the root. In the example, @hela/cli is just one of the packages of this monorepo.

lerna.json

{
  "packages": [
    "packages/*"
  ],
  "useWorkspaces": true,
  "npmClient": "yarn",
  "version": "3.0.0-alpha.66",
  "command": {
    "version": {
      "message": "chore(release): version %s"
    }
  }
}

lerna-debug.log

<!-- If you have a `lerna-debug.log` available, please paste it here -->
<!-- Otherwise, feel free to delete this <details> block -->

Context

Your Environment

Executable Version
lerna --version 3.15.0
npm --version 6.9.0
yarn --version 1.16.0
node --version 10.x
OS Version
NAME VERSION
ArchLinux none

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:6
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
dcwarwickcommented, Jun 23, 2021

OK, I have hit the same (I think) issue with lerna. We have a jest config that we put into its own package in our monorepo as it is used by several different other packages, and we want to use the same jest config for our top-level test suite, so I added the jest config package as a dev dependency to the root package.json, but the next time lerna version bumped the version for the jest config package everything broke because it did not update the version in the root package.json.

Is there a particular reason that lerna does not update versions of packages if they are mentioned in the root package.json? If there isn’t, can this be quite easily fixed? And if there is, how should I be going about setting up some shared resources that are used both by one or more of the packages in my monorepo and by tools run at the root level?

1reaction
evocateurcommented, Jul 18, 2019

I would use a relative file: specifier in the root, and have your build run in a prestart lifecycle, with start pointing to the built output path.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Salable Tech Blog 4; How to version all packages ...
In this post we will be exploring how to set up automatic versioning of packages inside of a monorepo using Lerna.
Read more >
How do I update all subfolder package.json in a monorepo to ...
I want to be able to update every package.json to their latest version, with one "global" command. Ideally, I'd like to use some...
Read more >
A Guide to Monorepos for Front-end Code - Toptal
Almost all operations in Lerna work via a simple rule—you iterate through all of your packages, and do some actions over them, e.g.,...
Read more >
Fine-tune Dependency Versions in Your JavaScript Monorepo
We've written before about how we use Yarn workspaces and Lerna to setup ... So, to fix our problem, we update our root...
Read more >
11 Great Tools for a Monorepo in 2021 | Bits and Pieces
Develop, build, and publish packages, and scale development. ... The version is kept in the lerna.json file at the root of your project...
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