2

I am learning React and while implementing my first react app, it shows me this error:

error Command "start" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

when I run:

yarn start

I have installed create-react-app globally on my machine.

I also tried to run npm start but it shows the same error, while searching on internet, I came to know that npm version 5.0 above may not work properly, and that is why I tried yarn start but it still shows the same error.

RobC
  • 22,977
  • 20
  • 73
  • 80
code_ghost
  • 49
  • 1
  • 4
  • Shouldn't it be `yarn run start`? – Dr. Acula Jun 04 '20 at 18:33
  • it is still displaying same error with "yarn run start" – code_ghost Jun 04 '20 at 18:35
  • 1
    You should NOT install `create-react-app` globally if you are have node verison `5.2+`. See [this](https://stackoverflow.com/a/62122386/2873538) and [docs](https://create-react-app.dev/docs/getting-started/) – Ajeet Shah Jun 04 '20 at 18:37
  • Can you add your package.json code? – Dr. Acula Jun 04 '20 at 18:38
  • @AjeetShah do i always have to install react, whenever i want to create new app ? – code_ghost Jun 04 '20 at 18:42
  • @soulLess here is package.json { "name": "confusion", "version": "0.1.0", "private": true, "dependencies": { "react": "^16.13.1", "react-dom": "^16.13.1", "react-scripts": "3.4.1" } } – code_ghost Jun 04 '20 at 18:43
  • You don't have a `start` command in your package.json, hence the error. – Dr. Acula Jun 04 '20 at 18:45
  • 1
    @code_ghost To start a new React project, each time you have to do `npx create-react-app my-app --use-yarn` or "--use-npm". "do i always have to install react": What do you mean? "React" is a UI library, yes it will be automatically get installed locally in each project you start. – Ajeet Shah Jun 04 '20 at 18:46
  • Does this answer your question? [Error: yarn start - error Command "start" not found](https://stackoverflow.com/questions/54393192/error-yarn-start-error-command-start-not-found) – Dr. Acula Jun 04 '20 at 18:46
  • How did you create your react project? "start" command should already be there if you used `create-react-app`. – Ajeet Shah Jun 04 '20 at 18:47
  • @AjeetShah First i installed ```create-react-app``` globally, then i used ```create-react-app project-name``` where whole lots of file got download, then used command ```yarn start``` and shows error. – code_ghost Jun 04 '20 at 18:53
  • 1
    @AjeetShah sir, thank you ```npx create-react-app my-app --use-yarn or "--use-npm" ``` worked. – code_ghost Jun 04 '20 at 19:03

0 Answers0