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.

Cannot specify `*` for node peer dependency version ranges.

See original GitHub issue

@* is a valid version range in NPM. It is useful in peerDependencies where it may not matter or may be difficult to specify a version range.

Current:

When package@* is given for a peer dependency, projen shows a prompt to resolve it to a specific version.

Feature Request:

package@* should be persisted in the peer dependencies in the package.json

Input:

peerDeps: ["package@*"]

Output

"peerDependencies": {
   "package": "*"
}

Example:

We have an issue in functionless where we need to specify * for a package that only has pre-release versions, but needs to match the version ranges of sibling packages.

Specifically,

Thus, any version range given by functionless peer dependencies (2.17.0-alpha.0) are pinned to a single @aws-cdk major/minor/patch version (2.17.0).

Supplying @aws-cdk/aws-appsync-alpha@* would resolve this issue without consumers using npm 7+ needing to force all “invalid” peer dependencies.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Chriscbrcommented, Apr 26, 2022

I think you’re right, auto-resolving “*” feels surprising especially when you’re declaring peer dependencies.

@thantos What if we support your use case like this?

project.deps.addDependency("package@*", DependencyType.PEER, { resolveVersion: false });

Currently this method already exists, just the “resolveVersion” part doesn’t do anything (yet).

0reactions
thantoscommented, Apr 27, 2022

We tried to use overrides https://projen.io/escape-hatches.html, but found that overrides cannot update fields that are managed by projen.

// does nothing
packageJson.addOverride("peerDependencies", { "somePeer": "*" } });

// works
packageJson.addOverride("hi", "there");
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error handling version ranges on peer dependencies #6802
I've downgraded to npm@1.4.28 and I still cannot reproduce this. The installation goes through just fine.
Read more >
Npm Including all range of pre-release when defining peer ...
Therefore, I am in need to add that package as peer-dependency into the package.json , so that npm and the user can be...
Read more >
Peer Dependencies | Node.js
For npm versions 3 through 6, you will receive a warning that the peerDependency is not installed instead.
Read more >
package.json - npm Docs
Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which...
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 >

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