diff --git a/packages/create-nx-workspace/src/utils/package-manager.ts b/packages/create-nx-workspace/src/utils/package-manager.ts index 30f248d2cb90f..9400fe7b25812 100644 --- a/packages/create-nx-workspace/src/utils/package-manager.ts +++ b/packages/create-nx-workspace/src/utils/package-manager.ts @@ -38,17 +38,15 @@ export function getPackageManagerCommand( exec: string; preInstall?: string; } { - const [pmMajor, pmMinor] = - getPackageManagerVersion(packageManager).split('.'); + const pmVersion = getPackageManagerVersion(packageManager); + const [pmMajor, pmMinor] = pmVersion.split('.'); switch (packageManager) { case 'yarn': const useBerry = +pmMajor >= 2; const installCommand = 'yarn install --silent'; return { - preInstall: useBerry - ? 'yarn set version stable' - : 'yarn set version classic', + preInstall: `yarn set version ${pmVersion}`, install: useBerry ? installCommand : `${installCommand} --ignore-scripts`, diff --git a/packages/nx/src/utils/package-manager.ts b/packages/nx/src/utils/package-manager.ts index 896f568efbb07..3a66103548642 100644 --- a/packages/nx/src/utils/package-manager.ts +++ b/packages/nx/src/utils/package-manager.ts @@ -65,9 +65,7 @@ export function getPackageManagerCommand( const useBerry = gte(yarnVersion, '2.0.0'); return { - preInstall: useBerry - ? 'yarn set version stable' - : 'yarn set version classic', + preInstall: `yarn set version ${yarnVersion}`, install: 'yarn', ciInstall: useBerry ? 'yarn install --immutable'