mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-15 17:42:31 -05:00
fix: add more info to the no matching version error message (#9225)
This commit is contained in:
6
.changeset/spicy-dingos-pull.md
Normal file
6
.changeset/spicy-dingos-pull.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/npm-resolver": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
When a package version cannot be found in the package metadata, print the registry from which the package was fetched.
|
||||
@@ -38,11 +38,11 @@ import { workspacePrefToNpm } from './workspacePrefToNpm'
|
||||
|
||||
export class NoMatchingVersionError extends PnpmError {
|
||||
public readonly packageMeta: PackageMeta
|
||||
constructor (opts: { wantedDependency: WantedDependency, packageMeta: PackageMeta }) {
|
||||
constructor (opts: { wantedDependency: WantedDependency, packageMeta: PackageMeta, registry: string }) {
|
||||
const dep = opts.wantedDependency.alias
|
||||
? `${opts.wantedDependency.alias}@${opts.wantedDependency.pref ?? ''}`
|
||||
: opts.wantedDependency.pref!
|
||||
super('NO_MATCHING_VERSION', `No matching version found for ${dep}`)
|
||||
super('NO_MATCHING_VERSION', `No matching version found for ${dep} while fetching it from ${opts.registry}`)
|
||||
this.packageMeta = opts.packageMeta
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ async function resolveNpm (
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
throw new NoMatchingVersionError({ wantedDependency, packageMeta: meta })
|
||||
throw new NoMatchingVersionError({ wantedDependency, packageMeta: meta, registry: opts.registry })
|
||||
}
|
||||
|
||||
const workspacePkgsMatchingName = workspacePackages?.get(pickedPackage.name)
|
||||
|
||||
@@ -828,6 +828,7 @@ test('error is thrown when there is no package found for the requested version',
|
||||
new NoMatchingVersionError({
|
||||
wantedDependency,
|
||||
packageMeta: isPositiveMeta,
|
||||
registry,
|
||||
})
|
||||
)
|
||||
})
|
||||
@@ -870,6 +871,7 @@ test('error is thrown when there is no package found for the requested range', a
|
||||
new NoMatchingVersionError({
|
||||
wantedDependency,
|
||||
packageMeta: isPositiveMeta,
|
||||
registry,
|
||||
})
|
||||
)
|
||||
})
|
||||
@@ -888,6 +890,7 @@ test('error is thrown when there is no package found for the requested tag', asy
|
||||
new NoMatchingVersionError({
|
||||
wantedDependency,
|
||||
packageMeta: isPositiveMeta,
|
||||
registry,
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user