Search code examples
javascriptreactjsnpmyarnpkg

Why is `npm init react-app` using yarn as default? (npm V6.14.5)


When running npm init react-app npm is choosing yarn as the default package manager for the created app. I have deleted yarn from my computer using boj answer in How Do I Uninstall Yarn.

Minimum reproducible example:

$ npm -v
6.14.5
$ npm init react-app my-app
npx: installed 98 in 13.198s

Creating a new React app in ./my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

yarn add v1.9.4
...
$ cd my-app
my-app/$ ls
node_modules  package.json  yarn.lock  public  README.md  src

As you can see there is a yarn.lock file and yarn add v1.9.4 was used for installing the packages. Is this the default npm behaviour right now as npm V6.14.5? If yes it would be great to know if there were a reference where I could find the reasons for choosing yarn as the default.


Solution

  • A reason could be that yarn is built with the Facebook team, so they would want to use it over npm.

    You can use --use-npm if you prefer npm:

    create-react-app my-project --use-npm
    

    If the project is already created, try deleting yarn.lock