Wish Nu
Wish Nu

Reputation: 31

Getting missing script: start error in npm

I get this error when I run npm start.

npm ERR! Missing script: "start"  
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! 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\USER\AppData\Local\npm-cache\_logs\2022-04-28T13_04_19_260Z-debug.log

Upvotes: 0

Views: 22815

Answers (8)

Rahul adya
Rahul adya

Reputation: 1

there will be an option to debug in the code above the scripts . just click on the debug option and click on start or build or whatever fuctionality you want to do.....

Upvotes: 0

Yash Katkar
Yash Katkar

Reputation: 1

if you are facing this issue for the react after creating the react app then always check for the folder are you in is correct or not .....? run cd "project name" and try npm start command again

Upvotes: 0

Aericki Ferreira
Aericki Ferreira

Reputation: 1

Do you have put node on Firewall settings public an private network

Upvotes: 0

Shambi Broome
Shambi Broome

Reputation: 1

Just happened to me and my package.json was correct. My fix was that I had something running on port 3000 & didn't realize it.

  1. I used the debugger on the "start" code line under "Scripts" in the package.json
  2. It told me something was already running on port 3000 then asked " Would you like to run the app on another port instead? (Y/N)
  3. I click my "Y" key - the debugger compiled and opened my app on port 3001
  4. Form I was trying to render loaded perfectly

Upvotes: 0

SanderM
SanderM

Reputation: 1

I had the same error and I had the "start" script and everything should have worked, but it didn't. What actually helped me eventually was just saving the changes, ctrl+s. That's it, I just had to save changes and then it worked.

Upvotes: 0

Gep Sher
Gep Sher

Reputation: 27

  • Option_1: Control inside file "package.json":
"scripts": {            
    "start": "what command is here?",                  
    },
  • Option_2: Control Terminal (folder) where you write command OR open the responding terminal for your project: right-click on the project name -> "Open in integrated Terminal"

Upvotes: 1

Amit
Amit

Reputation: 1143

package.json has various sections, scripts is one of them, which allows you to write npm scripts which we can run using npm run <script-name>. The error you're getting is because your start script is missing in that section.

For a node app, your package.json file should look similar to this.

{
    "name": "server",
    "version": "1.0.0",
    "description": "",
    "main": "app.js",
    "scripts": {
        "start": "node app.js",
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "dependencies": {
        "body-parser": "^1.20.0",
        "cors": "^2.8.5",
        "express": "^4.17.3"
    }
}

In the above code, focus on the scripts section. The following line is missing in your package.json file.

"scripts": {
    "start": "node app.js",
},

Add this line and you're good to go.

Upvotes: 1

Mohana Sundaram S
Mohana Sundaram S

Reputation: 180

You have to put what command you need npm to run when you give npm start.

enter image description here

You have to write node index.js in scripts.start in your package.json file

Upvotes: -1

Related Questions