Search code examples
reactjslinuxubuntunpmyarnpkg

How to create react app using yarn instead of npm?


The offical way to create react app is mentioned in react documentation

i think npx create-react-app project automatically detect yarn but in my case it doesn't and create react app using npm which i don't want.

Second option for me to use yarn create react-app for creating react app but it shows multiple warnings:

warning " > @testing-library/user-event@13.5.0" has unmet peer dependency "@testing-library/dom@>=7.21.4".
warning "react-scripts > tailwindcss@3.0.22" has unmet peer dependency "autoprefixer@^10.0.2".
warning "react-scripts > eslint-config-react-app > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-syntax-flow@^7.14.5".
warning "react-scripts > eslint-config-react-app > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-transform-react-jsx@^7.14.9".
warning "react-scripts > react-dev-utils > fork-ts-checker-webpack-plugin@6.5.0" has unmet peer dependency "typescript@>= 2.7".
warning "react-scripts > eslint-config-react-app > @typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".

so is there any better way to create react app with npx (that uses yarn)


Solution

  • As far as I understand, in create-react-app@version-5.0 and above, the expected behavior is:

    • To create a project based on npm

      npm init react-app my-app
      

      or

      npx create-react-app my-app
      
    • To creates a project based on yarn

      yarn create react-app my-app
      

    See official docs or this thread