Skip to content

installNodeModules() uses wrong subcommand for yarn/pnpm when adding specific packages #7042

@umxr

Description

@umxr

Problem

installNodeModules() in packages/cli-kit/src/public/node/node-package-manager.ts always runs <pm> install <packages>, but yarn and pnpm require add instead of install when adding specific packages with version specifiers.

This caused hydrogen upgrade to fail on yarn projects, and would similarly fail on pnpm.

Current behavior

let args = ['install']
if (options.args) {
  args = args.concat(options.args)
}
await exec(options.packageManager, args, execOptions)

This produces commands like:

  • yarn install @shopify/hydrogen@2025.7.1fails (install has been replaced with add)
  • pnpm install @shopify/hydrogen@2025.7.1fails (pnpm install installs from lockfile, not specific packages)

Expected behavior

When specific packages are passed via args, the correct subcommand should be used per package manager:

Package Manager Correct Subcommand
npm install
yarn add
pnpm add
bun install

Workaround

Shopify/hydrogen#3462 bypassed installNodeModules() with a direct exec() call that maps the correct subcommand per package manager. Once this upstream fix lands, that workaround can be removed.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions