How do I get the "version range" or "specifier" of a package when using catalogs? #10221
Unanswered
tringenbach
asked this question in
Q&A
Replies: 1 comment
-
|
A few options: 1. Parse the lockfile catalogs:
default:
lodash: ^4.17.21Read with: cat pnpm-lock.yaml | yq ".catalogs.default.lodash"2. Direct catalog lookup from workspace file yq ".catalog.lodash" pnpm-workspace.yaml3. For programmatic access import { readWantedLockfile } from "@pnpm/lockfile.fs";
const lockfile = await readWantedLockfile(".", { ignoreIncompatible: true });
console.log(lockfile.catalogs);4. Check resolved specifier in lockfile importers importers:
packages/app:
dependencies:
lodash:
specifier: catalog:
version: 4.17.21The lockfile approach is most reliable since it handles overrides and workspace protocols too. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When using a catalog, is there a good way to find out the "version range" of a package? By "version range" I mean
^1.2.3or>5.4.3or whatever the version spec is. Note that I don't want to know the exact version. And I'd rather not parse thepnpm-workspaces.ymlmyself. Ideally the solution would handleworkspace:, andoverridestoo.I would have thought that
pnpm whyor maybepnpm listwould give this information but it does not seem to.So far the best solution I've found is to run
pnpm packand inspect the package.json in the generated tarball. But that's a bit inconvenient, and won't give me the answer for "dependencies of my dependencies" the waypnpm whywould.Maybe the right answer is to consult the
pnpm-lock.yamlfile myself?Beta Was this translation helpful? Give feedback.
All reactions