diff --git a/packages/default-reporter/src/reportError.ts b/packages/default-reporter/src/reportError.ts index 0c305ed881..ace50ad64d 100644 --- a/packages/default-reporter/src/reportError.ts +++ b/packages/default-reporter/src/reportError.ts @@ -79,11 +79,15 @@ function reportUnexpectedStore (err: Error, msg: object) { return stripIndent` ${formatErrorSummary(err.message)} - expected: ${highlight(msg['expectedStorePath'])} - actual: ${highlight(msg['actualStorePath'])} + The dependencies at "${msg['modulesDir']}" are currently linked from the store at "${msg['expectedStorePath']}". - If you want to use the new store, run the same command with the ${highlight('--force')} parameter. - ` + pnpm now wants to use the store at "${msg['actualStorePath']}" to link dependencies. + + If you want to use the new store location, reinstall your dependencies with "pnpm install --force". + + You may change the global store location by running "pnpm config set store ". + (This error may happen if the node_modules was installed with a different major version of pnpm) + ` } function reportStoreBreakingChange (msg: object) { diff --git a/packages/supi/src/getContext/checkCompatibility/UnexpectedStoreError.ts b/packages/supi/src/getContext/checkCompatibility/UnexpectedStoreError.ts index c99f4e1a59..1d658b7c87 100644 --- a/packages/supi/src/getContext/checkCompatibility/UnexpectedStoreError.ts +++ b/packages/supi/src/getContext/checkCompatibility/UnexpectedStoreError.ts @@ -3,14 +3,17 @@ import { PnpmError } from '../../errorTypes' export default class UnexpectedStoreError extends PnpmError { public expectedStorePath: string public actualStorePath: string + public modulesDir: string constructor ( opts: { expectedStorePath: string, actualStorePath: string, + modulesDir: string, }, ) { - super('ERR_PNPM_UNEXPECTED_STORE', 'Unexpected store used for installation') + super('ERR_PNPM_UNEXPECTED_STORE', 'Unexpected store location') this.expectedStorePath = opts.expectedStorePath this.actualStorePath = opts.actualStorePath + this.modulesDir = opts.modulesDir } } diff --git a/packages/supi/src/getContext/checkCompatibility/index.ts b/packages/supi/src/getContext/checkCompatibility/index.ts index 52aa22da25..380ee7925a 100644 --- a/packages/supi/src/getContext/checkCompatibility/index.ts +++ b/packages/supi/src/getContext/checkCompatibility/index.ts @@ -8,7 +8,7 @@ export default function checkCompatibility ( modules: Modules, opts: { storePath: string, - modulesPath: string, + modulesDir: string, }, ) { // Important: comparing paths with path.relative() @@ -19,11 +19,12 @@ export default function checkCompatibility ( throw new UnexpectedStoreError({ actualStorePath: opts.storePath, expectedStorePath: modules.store, + modulesDir: opts.modulesDir, }) } if (!modules.layoutVersion || modules.layoutVersion !== LAYOUT_VERSION) { throw new ModulesBreakingChangeError({ - modulesPath: opts.modulesPath, + modulesPath: opts.modulesDir, }) } } diff --git a/packages/supi/src/getContext/index.ts b/packages/supi/src/getContext/index.ts index 712d214df9..a510a04391 100644 --- a/packages/supi/src/getContext/index.ts +++ b/packages/supi/src/getContext/index.ts @@ -183,7 +183,7 @@ async function validateNodeModules ( + ' You must remove that option, or else add the --force option to recreate the "node_modules" folder.', ) } - checkCompatibility(modules, { storePath: opts.store, modulesPath: importer.modulesDir }) + checkCompatibility(modules, { storePath: opts.store, modulesDir: importer.modulesDir }) if (opts.lockfileDirectory !== importer.prefix && opts.include && modules.included) { for (const depsField of DEPENDENCIES_FIELDS) { if (opts.include[depsField] !== modules.included[depsField]) {