Skip to content

improve Node.js package manager detection #12001

@josefaidt

Description

@josefaidt

Is this feature request related to a new or existing Amplify category?

No response

Is this related to another service?

No response

Describe the feature you'd like to request

Improve detection of the developer's chosen Node.js package manager, which applies to the following workflows:

  • auto-installing Node.js Function dependencies on build/push
  • auto-installing dependencies in the Sandbox workflow

examples:

Describe the solution you'd like

Amplify CLI automatically detects the package manager of choice for JavaScript projects

// https://github.com/vercel/next.js/blob/canary/packages/create-next-app/helpers/get-pkg-manager.ts
export type PackageManager = 'npm' | 'pnpm' | 'yarn'

export function getPkgManager(): PackageManager {
  const userAgent = process.env.npm_config_user_agent

  if (userAgent) {
    if (userAgent.startsWith('yarn')) {
      return 'yarn'
    } else if (userAgent.startsWith('pnpm')) {
      return 'pnpm'
    } else {
      return 'npm'
    }
  } else {
    return 'npm'
  }
}

Describe alternatives you've considered

n/a

Additional context

Is this something that you'd be interested in working on?

  • 👋 I may be able to implement this feature request

Would this feature include a breaking change?

  • ⚠️ This feature might incur a breaking change

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest a new featurep3platformIssues tied to the general CLI platform

    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