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.

Managing peerDependency versions at the root

See original GitHub issue

Expected Behavior

As a developer, I’d like to be able to manage SOME of my packages’ peerDependencies at the root of my project.

Directory structure

package.json
| -- packages
     | -- foo
         | -- package.json
     | -- bar
         | -- package.json

foo’s package.json

{
  ...
  "peerDependencies": {
    "@angular/core": "NG_VERSION"
  } 
  ...
}

bar’s package.json

{
  ...
  "peerDependencies": {
    "@angular/core": "NG_VERSION"
  } 
  ...
}

root package.json

{
  ...
  "dependencies": {
    "@angular/core": "^8.0.0"
  } 
  ...
}

Current Behavior

I couldn’t find anything in the docs regarding this model, and as it stands, this makes version management of common packages across a large number of libraries extremely painful.

Possible Solution

Provide a way to link the peerDependency of a package to the root’s version.

lerna.json

{
  "packages": [
    "apps/*",
    "libs/*"
  ],
  "version": "0.0.1"
}

Context

I’d like to make common version management of my packages easier.

Your Environment

lerna --version
3.13.1

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
damienwebdevcommented, Jun 18, 2019

@MunifTanjim what I’m saying is that when I run lerna publish I would like to use the variable version from the root as opposed to having to manage the same peerDependency in each package that depends upon it within my monorepo.

Apologies for the lack of clarity.

For example, if you publish fifteen libraries that depend on "react" : "^6.0.0" from the same monorepo, I would like to make sure that I don’t have to increment the react peerDependency in every single package when react publishes a new major version. I would instead like to be able to define it at the root and utilize the root version at publish time for lerna publish.

lerna.json
{
 "variables": {
    "NG_VERSION" : "^8.0.0"
  }
}

would even be sufficient.

0reactions
RoryHcommented, Nov 29, 2022

FEATURE

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Peer Dependencies in JavaScript
In this case, you would declare React as a peer dependency for your components, because you want the host project to have the...
Read more >
npm Peer Dependencies - Fathom
When specifying the allowed versions of a package in a peer dependency in our package.json , we often want to specify more liberal...
Read more >
npm Peer Dependencies - JavaScript inDepth
Peer Dependencies are used to specify that our package is compatible with a specific version of an npm package. Good examples are Angular...
Read more >
npm: refer to a peer dependency; how to align the version ...
I'm using the root function from that library and, in fact, if dependency-A bumps the version, I'd like to align with it and...
Read more >
[Fixed] NPM conflicting peer dependency error
NPM is a great tool to manage packages for your projects, ... Installing NPM modules using NPM version 7.11.1 npm ERR! code ERESOLVE...
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