Find multiple versions of dependencies from pnpm lockfile.
npm i pnpm-multi-versionspnpx pnpm-multi-versions
# Multiple versions packages:
# pkg-types: 1.3.1, 2.3.0
# quansync: 0.2.11, 1.0.0
# Show dependents for each version
pnpx pnpm-multi-versions --dependents
# Single package:
# pkg-types
# ├─ 1.3.1 [email protected]
# └─ 2.3.0 [email protected], [email protected], [email protected]
#
# Multiple packages:
# ┌─ pkg-types
# │ ├─ 1.3.1 [email protected]
# │ └─ 2.3.0 [email protected], [email protected], [email protected]
# └─ quansync
# ├─ 0.2.11 [email protected]
# └─ 1.0.0 @quansync/[email protected], [email protected]
const lockfile = await readLockfile('pnpm-lock.yaml')
const { versionsMap, dependentsMap, multipleVersions } = pnpmMultiVersions(lockfile, {
/** Ignore major version difference */
ignoreMajor: false,
/** Show dependents for each version */
dependents: true,
})
console.log(versionsMap)
// Map(2) {
// "pkg-types" => Set(2) { '1.3.1', '2.3.0' },
// "quansync" => Set(2) { '0.2.11', '1.0.0' },
// ...
// }
console.log(dependentsMap)
// Map(2) {
// "pkg-types" => Map(2) {
// "1.3.1" => Set(1) { 'mlly@1.8.0' },
// "2.3.0" => Set(3) { 'c12@3.3.3', '[email protected]', '[email protected]' }
// },
// "quansync" => Map(2) {
// "0.2.11" => Set(1) { 'local-pkg@1.1.2' },
// "1.0.0" => Set(2) { '@quansync/fs@1.0.0', '[email protected]' }
// }
// }
console.log(multipleVersions)
// Set(2) { 'pkg-types', 'quansync' }MIT License © 2025 Kevin Deng