Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn is used automatically with no obvious way to use npm instead #3385

Closed
codazoda opened this issue Nov 1, 2017 · 5 comments · Fixed by #3409
Closed

Yarn is used automatically with no obvious way to use npm instead #3385

codazoda opened this issue Nov 1, 2017 · 5 comments · Fixed by #3409

Comments

@codazoda
Copy link

codazoda commented Nov 1, 2017

Summary

create-react-app uses yarn for the setup if it's installed. I prefer npm alone but I have yarn installed because it's necessary for some of the projects I work on. I'd like to be able to use npm instead of yarn when creating a new app with create-react-app.

create-react-app tests for yarn by running yarn --version. Other scripts in the react-scripts directory then look for the yarn.lock file and key off of that.

Possible Solutions

I'm prepared to update the code and create a pull request based on the result of this discussion. Here are a few of the solutions I have considered.

  • Have create-react-app tell the user it used yarn and simply suggest deleting yarn.lock to use npm instead
  • Use an environment variable such as USE_YARN=no
  • Have create-react-app prompt the user if they would like to use yarn if it's installed
  • Don't solve the problem

The contributing documentation suggests against using config options, so I didn't offer that as a solution. I'm leaning toward the first solution in that list.

More Solution Details

One option is to simply inform the user that yarn was used and offer the suggestion that they can delete the yarn.lock file to use npm instead. Substituting npm for the yarn commands listed above that prompt. This seems like a pretty simple solution but it does require the user delete a file and it also adds some additional messaging to the app that might better belong in documentation somewhere.

Another option is to allow overriding the usage of yarn by looking for an environment variable such as USE_YARN=no. This would not be obvious to the user but could be covered in the documentation.

We might also solve the problem by having create-react-app prompt the user. The contributing doc suggests that interactivity is preferred over configuration flags. A prompt, however, would interrupt the user every time they run create-react-app just because they have yarn installed. Many users might prefer the default behavior of using yarn so this is an unwanted interruption.

Finally, we could do nothing and a developer could simply delete the yarn.lock file after creating a new project. This isn't covered in any messaging or documentation, however, so the solution wasn't obvious to me until after I dug into the source code.

Discussion

I'm happy to send a pull request to solve the problem but I'd like to know how the community would like it solved (if at all).

@codazoda codazoda changed the title Yarn is used automatically with no obvious way to use NPM instead. Yarn is used automatically with no obvious way to use npm instead Nov 1, 2017
@gaearon
Copy link
Contributor

gaearon commented Nov 1, 2017

How about:

create-react-app app --use-npm

?

@codazoda
Copy link
Author

codazoda commented Nov 1, 2017

@gaearon The contributing documentation suggests against using command line config options, so I didn't offer that as a solution.

@gaearon
Copy link
Contributor

gaearon commented Nov 1, 2017

Generally trying to avoid them but creating a project happens just once per project so not a big deal. Happy to take a PR for this.

@tabrindle
Copy link
Contributor

tabrindle commented Nov 4, 2017

I was playing around in this code the other day, and it seemed like a trivial thing to implement. Let me know if this makes sense! #3409

@gaearon
Copy link
Contributor

gaearon commented Jan 15, 2018

This is out! Please let us know if something doesn’t quite work.
https://github.com/facebookincubator/create-react-app/releases/tag/v1.1.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants