fix: print a hint on integrity error (#6090)

ref #6087
This commit is contained in:
Zoltan Kochan
2023-02-16 04:25:06 +02:00
committed by GitHub
parent 673e230607
commit 2241f77adf
2 changed files with 14 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/tarball-fetcher": patch
"pnpm": patch
---
Print a hint that suggests to run `pnpm store prune`, when a tarball integrity error happens.

View File

@@ -27,7 +27,14 @@ export class TarballIntegrityError extends PnpmError {
}) {
super('TARBALL_INTEGRITY',
`Got unexpected checksum for "${opts.url}". Wanted "${opts.expected}". Got "${opts.found}".`,
{ attempts: opts.attempts }
{
attempts: opts.attempts,
hint: `This error may happen when a package is republished to the registry with the same version.
In this case, the metadata in the local pnpm cache will contain the old integrity checksum.
If you think that this is the case, then run "pnpm store prune" and rerun the command that failed.
"pnpm store prune" will remove your local metadata cache.`,
}
)
this.found = opts.found
this.expected = opts.expected