Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !12366

fix(create-react-app): improve Yarn 2+ support

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/larixer/main into main May 05, 2022
  • Overview 5
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: larixer

Yarn 2+ getting started instructions advise to use Yarn 2+ via corepack. corepack is shipped with the latest versions of Node 14.x, 16.x and future Node versions. corepack uses Yarn 1.x by default for all the CLI commands that are available only in Yarn 1.x or both in Yarn 1.x and Yarn 2+. However yarn dlx cli command which become available in Yarn 2+ only gets routed to Yarn 2+ by corepack.

When the user has corepack enabled and executes yarn dlx create-react-app, he naturally should expect that the initialized React app will use Yarn 2+. This PR is devoted to make this happen.

The PR gets Yarn version from process.env.npm_config_user_agent and stores it into packageManager field of package.json in the generated app. corepack uses packageManager field and routes all the yarn ... command to the Yarn version specified in this field.

Credits should go to @merceyz for the process.env.npm_config_user_agent idea.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/larixer/main