From 499882ae56fccd408f18d4487d5dca2ea60531f0 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Thu, 19 Sep 2024 11:50:01 +0200 Subject: [PATCH] Merge pull request #29152 from storybookjs/valentin/fix-package-manager-addition-to-package-json Core: Do not add packageManager field to package.json during `storybook dev` (cherry picked from commit 57ee6e198fd1ffd5227c72e78bd1cd04b19c4d89) --- .../JsPackageManagerFactory.ts | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/code/core/src/common/js-package-manager/JsPackageManagerFactory.ts b/code/core/src/common/js-package-manager/JsPackageManagerFactory.ts index 7477a1e5f2c..4b3c6184e59 100644 --- a/code/core/src/common/js-package-manager/JsPackageManagerFactory.ts +++ b/code/core/src/common/js-package-manager/JsPackageManagerFactory.ts @@ -125,17 +125,35 @@ export class JsPackageManagerFactory { } function hasNPM(cwd?: string) { - const npmVersionCommand = spawnSync('npm', ['--version'], { cwd, shell: true }); + const npmVersionCommand = spawnSync('npm', ['--version'], { + cwd, + shell: true, + env: { + COREPACK_ENABLE_STRICT: '0', + }, + }); return npmVersionCommand.status === 0; } function hasPNPM(cwd?: string) { - const pnpmVersionCommand = spawnSync('pnpm', ['--version'], { cwd, shell: true }); + const pnpmVersionCommand = spawnSync('pnpm', ['--version'], { + cwd, + shell: true, + env: { + COREPACK_ENABLE_STRICT: '0', + }, + }); return pnpmVersionCommand.status === 0; } function getYarnVersion(cwd?: string): 1 | 2 | undefined { - const yarnVersionCommand = spawnSync('yarn', ['--version'], { cwd, shell: true }); + const yarnVersionCommand = spawnSync('yarn', ['--version'], { + cwd, + shell: true, + env: { + COREPACK_ENABLE_STRICT: '0', + }, + }); if (yarnVersionCommand.status !== 0) { return undefined;