How to create react app using yarn instead of npm?

Viewed 933

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)

1 Answers

There is no need to use yarn for create-react-app as this npm package is not a local dev dependency. It's used to download a template of a React project and react-scripts package does all the "magic" stuff.

The reason why the official documentation suggests using npx is that it will delete the package after it's used to create a template. This mean when you want to create another react project, it will always use the latest version of create-react-app.

Related