Skip to content

Commit 9afba8b

Browse files
author
Umar Gora
committed
Fix hydrogen upgrade failing with yarn and pnpm
The upgrade command was using `installNodeModules` which always runs `<pm> install <packages>`. This works for npm but fails for yarn, pnpm, and bun which require `add` instead of `install` when adding/upgrading specific packages. Mirror the pattern already used by `uninstallNodeModules` which correctly maps the subcommand per package manager.
1 parent a2ce62b commit 9afba8b

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/cli-hydrogen': patch
3+
---
4+
5+
Fix `hydrogen upgrade` failing with yarn by using `yarn add` instead of `yarn install` when upgrading dependencies

packages/cli/src/commands/hydrogen/upgrade.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
} from '@shopify/cli-kit/node/fs';
2424
import {
2525
getDependencies,
26-
installNodeModules,
2726
getPackageManager,
2827
type PackageJson,
2928
} from '@shopify/cli-kit/node/node-package-manager';
@@ -903,10 +902,13 @@ export async function upgradeNodeModules({
903902
tasks.push({
904903
title: `Upgrading dependencies`,
905904
task: async () => {
906-
await installNodeModules({
907-
directory: appPath,
908-
packageManager: await getPackageManager(appPath),
909-
args: upgradeArgs,
905+
const packageManager = await getPackageManager(appPath);
906+
const command = packageManager === 'npm' ? 'install' : 'add';
907+
const actualPackageManager =
908+
packageManager === 'unknown' ? 'npm' : packageManager;
909+
910+
await exec(actualPackageManager, [command, ...upgradeArgs], {
911+
cwd: appPath,
910912
});
911913
},
912914
});

0 commit comments

Comments
 (0)