1

I'm newbie to react js.Trying to run a simple app and getting this error and can't figure out what's wrong

D:\React app\react-app1>npm start
npm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Muralidharan\AppData\Local\npm-cache\_logs\2022-05-29T08_51_37_315Z-debug-0.log

This is package.json file

{
  "name": "react-app1",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^18.1.0",
    "react-dom": "^18.1.0",
    "react-scripts": "5.0.1"
  }
}

Anything wrong with installation? or outdated version something like that?

3
  • Can you show your package.json and especially the scripts property? Commented May 29, 2022 at 9:10
  • I have added it in the question ,can you please look at it ? Commented May 29, 2022 at 9:13
  • 1
    Thank you. Then please look at the answer from @Seblor - you need at least a script for starting the application. When you call "npm start", npm looks into your package.json and tries to find a command under scripts > start. And your package.json doesn't have it Commented May 29, 2022 at 9:15

2 Answers 2

1

This happens becaue you have no script called "start" in your package.json file. Here is an example of a package.json file with such script:

{
  "name": "your-project",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "start": "node main.js"
  },
  "author": "Muralidharan",
  "dependencies": {
  }
}
Sign up to request clarification or add additional context in comments.

2 Comments

Should I add these part "scripts": { "start": "node main.js" } to my package.json file ?
@Muralidharan Well it depends on the name of the entrypoint JS file. If your file is called "app.js", the script will be "start": "node app.js". But otherwise that's pretty much it. npm start is a shorthand for npm run start, so you can read the documentation here : docs.npmjs.com/cli/v8/commands/npm-run-script
0

add this to your package.json

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

start is the command you need that trigger react-script to run your project build, test and eject are other command you will need for development process

Comments

Your Answer

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