Skip to content

Optionally replace yarn in templates #11157

@jamesplease

Description

@jamesplease

Is your proposal related to a problem?

Custom CRA templates automatically replace npm run with yarn in "scripts". This is described as being for convenience, but for my use case it isn't convenient. I build internal tools and try to ensure that they work for as many developers as possible. At my company, some developers use npm, and others use yarn. For this reason, I exclusively use npm run always to maximize environment compatibility.

This works because all JS developers have Node installed, and npm comes bundled with Node. However, yarn does not come with Node, so it is an additional dependency that must be installed separately.

Today, a developer who uses npm ran into an issue because they did not have yarn installed. The template I created specifies npm run, but CRA had replaced it behind-the-scenes with yarn.

Describe the solution you'd like

Ideally, this replacement wouldn't happen at all. If folks want yarn in their scripts, then they will likely specify that themselves.

A non-breaking solution would be to enable this as an option. Perhaps a new property in template.json that could removed by CRA during installation, such as:

{
  "persistNpmRun": true
}

Describe alternatives you've considered

N/A

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions