I recently installed yarn on my machine but was using npm before. For my current project in React I want to use npm again.
However, if I run create-react-app it is built with yarn.
How can I switch so that it is created with npm?
Create React App is a comfortable environment for learning React, and is the best way to start building a new single-page application in React. npx on the first line is not a typo — it's a package runner tool that comes with npm 5.2+.
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.
As I noted above, npm comes preinstalled with Node, so there's no need to install npm manually. In this case, berry is the version we want to set. With Yarn we can use a different version for each project. To do the same with npm, you'll need to have nvm (Node Version Manager) installed.
You can use the --use-npm
flag:
create-react-app my-project --use-npm
If it's an existing project you can just remove yarn.lock
and continue using it with npm
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With