5

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/[email protected]" has unmet peer dependency "@testing-library/dom@>=7.21.4".
warning "react-scripts > [email protected]" has unmet peer dependency "autoprefixer@^10.0.2".
warning "react-scripts > eslint-config-react-app > [email protected]" has unmet peer dependency "@babel/plugin-syntax-flow@^7.14.5".
warning "react-scripts > eslint-config-react-app > [email protected]" has unmet peer dependency "@babel/plugin-transform-react-jsx@^7.14.9".
warning "react-scripts > react-dev-utils > [email protected]" has unmet peer dependency "typescript@>= 2.7".
warning "react-scripts > eslint-config-react-app > @typescript-eslint/eslint-plugin > [email protected]" 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)

2 Answers 2

10

As far as I understand, in [email protected] 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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

3 Comments

I mean to say that whenever I write npx create-react-app so it generates react app with package-lock.json but I want it to generate yarn.lock
@SulemanElahi I guess this should help - stackoverflow.com/a/61938578/8203841
I meant to say that we use npm to install packages like npm install package-name and when we use yarn we usally do something like yarn add package-name so is there any alternative of npx in yarn package manager right now we have yarn create react-app that is alternative of npx create-react-app thanks for comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.