'npm ERR! missing script: start (react.js)

I've searched in previous answers and tried to solve this for many hours but with no success. I've typed in the terminal npm create-react-app, moved to the correct cd, and it gives me this error:

'npm ERR! missing script: start'

And this is my package.json

{
  "name": "react-project",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  }

}

It doesn't make sense to me. help?



Solution 1:[1]

Your package.json is missing a start script. It should be something like

{
  "name": "react-project",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start"
  },
}

Where react-scripts start is the command to start your app.

Also, you ran incorrect command. It should be

npx create-react-app my-app

Solution 2:[2]

Not sure what you did or what caused that but you're missing scripts in your package which should be generated by create-react-app:

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

Ah, got it. You used wrong command:

npm react-create-app

Which only inited your package.json. You should run:

npm create-react-app

Solution 3:[3]

First, use a code editor to open the folder where you put the react file, and open package.json.

Then, add the below code lines. Don't forget ",", before or after it depends on where you put it. Think about how you put properties in an object.

"scripts": {
    "start": "react-scripts start"
}

Then, save, run npm start on your command line or terminal.

Solution 4:[4]

Add the following to your package.json:

{
  "name": "react-project",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  }

}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2
Solution 3 Paul Roub
Solution 4 Adam