-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Comments
How about:
? |
@gaearon The contributing documentation suggests against using command line config options, so I didn't offer that as a solution. |
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. |
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 |
This is out! Please let us know if something doesn’t quite work. |
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 thereact-scripts
directory then look for theyarn.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.
USE_YARN=no
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 theyarn
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).
The text was updated successfully, but these errors were encountered: