Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch to npm for create-react-app

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?

like image 752
Oliver Avatar asked Jun 26 '18 17:06

Oliver


People also ask

Can I use npm With create React app?

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+.

Does create React app use npm or yarn?

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.

Can we use npm instead of yarn?

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.


2 Answers

You can use the --use-npm flag:

create-react-app my-project --use-npm
like image 65
Tholle Avatar answered Oct 04 '22 03:10

Tholle


If it's an existing project you can just remove yarn.lock and continue using it with npm.

like image 37
Aliaksandr Sushkevich Avatar answered Oct 04 '22 01:10

Aliaksandr Sushkevich