NPM start will not work in iTerm

I am working on a React project and noticed issues when trying to run npm start to view my project on the local host. It says that I am missing the script start, but that is not true. I checked my package.json file and it is definitely there. I ran the run/debug in my package.json and it launched to the local host just fine. However, if I run npm start in my iTerm it still gives the same error. Any advice/insight is much appreciated

here is the error in my iTerm

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: /Users/cassiusreynolds/.npm/_logs/2023-06-28T21_40_58_049Z-debug-0.log

here is the scripts in my package.json file

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

The most common scenario is that you aren’t running the command from the correct location. Make sure your terminal is in the root of your project.

1 Like

What was the command that worked for you?

Not sure if it’s true but some people are suggesting that using the old globally installed create-react-app might cause the error. If so you might need to remove it and create a new app.

npm uninstall -g create-react-app

npx clear-npx-cache

npx create-react-app my-app

Or you can try to remove the globally installed create-react-app and just update the project.

Both have the potential to introduce breaking changes so test it on a backup of the project first.

I’m pretty sure if you run npm start in a folder without a package.json file you will get some error about “no such file or directory”. I think you only get the Missing script error if it actually finds a package.json file. But I guess it is possible you are in the wrong folder but it has a package.json file.

1 Like

thank you for the reply. I did not notice until ArielLeslie pointed it out, but I actually forgot to cd into my react app after creating it bc the other folder had a very similar name. So, I was never in the root of the project. Thank you for the warning against installing globally!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.