diff --git a/.changeset/poor-cars-battle.md b/.changeset/poor-cars-battle.md new file mode 100644 index 000000000000..5832e363cadd --- /dev/null +++ b/.changeset/poor-cars-battle.md @@ -0,0 +1,5 @@ +--- +"@astrojs/upgrade": patch +--- + +Updates the command used for installing packages with pnpm and yarn diff --git a/packages/upgrade/src/actions/install.ts b/packages/upgrade/src/actions/install.ts index 3f343463fadf..3c294a8ee2a5 100644 --- a/packages/upgrade/src/actions/install.ts +++ b/packages/upgrade/src/actions/install.ts @@ -123,6 +123,9 @@ async function runInstallCommand( const cwd = fileURLToPath(ctx.cwd); if (ctx.packageManager === 'yarn') await ensureYarnLock({ cwd }); + const installCmd = + ctx.packageManager === 'yarn' || ctx.packageManager === 'pnpm' ? 'add' : 'install'; + await spinner({ start: `Installing dependencies with ${ctx.packageManager}...`, end: `Installed dependencies!`, @@ -132,7 +135,7 @@ async function runInstallCommand( await shell( ctx.packageManager, [ - 'install', + installCmd, ...dependencies.map( ({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, '')}` ), @@ -144,7 +147,7 @@ async function runInstallCommand( await shell( ctx.packageManager, [ - 'install', + installCmd, '--save-dev', ...devDependencies.map( ({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, '')}` @@ -161,7 +164,7 @@ async function runInstallCommand( error( 'error', `Dependencies failed to install, please run the following command manually:\n${color.bold( - `${ctx.packageManager} install ${packages}` + `${ctx.packageManager} ${installCmd} ${packages}` )}` ); return ctx.exit(1);