0

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
2
  • it is probably something like npm run start. otherwise check your package.json file, under the property script it shows you the available scripts for the project Commented Apr 28, 2022 at 13:22
  • Edit your question to include your package.json and read the docs for npm start where it says you need a start script like "scripts": { "start": "node foo.js" } Commented Apr 28, 2022 at 13:28

8 Answers 8

1

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.

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

Comments

1
  • 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"

Comments

0

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.

Comments

0

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

Comments

0

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

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
0

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

Comments

0

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.....

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
-1

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

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.