fix: print a hint about the package-manager-strict setting (#7960)

close #7956
This commit is contained in:
Zoltan Kochan
2024-04-18 13:18:30 +02:00
committed by GitHub
parent d87d36e82e
commit a80b539c36
2 changed files with 9 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/cli-utils": patch
"pnpm": patch
---
Print a hint about the `package-manager-strict` setting, when pnpm doesn't match the version specified in the `packageManager` field in `package.json`.

View File

@@ -38,7 +38,9 @@ export function packageIsInstallable (
if (pmVersion && pnpmVersion && pmVersion !== pnpmVersion) {
const msg = `This project is configured to use v${pmVersion} of pnpm. Your current pnpm is v${pnpmVersion}`
if (opts.packageManagerStrict) {
throw new PnpmError('BAD_PM_VERSION', msg)
throw new PnpmError('BAD_PM_VERSION', msg, {
hint: 'If you want to bypass this version check, you can set the "package-manager-strict" configuration to "false" or set the "COREPACK_ENABLE_STRICT" environment variable to "0"',
})
} else {
globalWarn(msg)
}