NPM Start Error
Easy solution for a common rookie mistake by React users
This will be a short but highly significant blog post that will help many React newcomers and even some veterans as well.
I’ve lost count of the number of times I’ve initially generated a new React app project by running the command-line tool create-react-app and the name of my app, then watching the myriad of processes flash in my terminal. Then eagerly running npm start, only to be met with the line of errors below:
If you start googling the errors, you get a lot of different answers that will have you making all kinds of unnecessary coding acrobatics if you haven’t made a basic check first, that could quickly remedy this problem.
Notice what folder I’m currently in:
This seasons folder is the folder that contains my React project. I actually need to be inside of my React project folder when I run npm start. So, I simply cd into my React project folder which is named frontend_season:
Now that I’m in my React project folder, frontend_season, I can run npm start:
My back end (named backend_season) is already running on port 3000, so I get a message asking if I want to run my front end on an alternate port.
I enter Y for yes and voilà:
My React project is up and running!
So remember, when your npm start is met with a line of errors, FIRST check to make sure you’re running it from inside of your React project folder. Then you won’t be making a bunch of unnecessary changes to your app that will only make things worse.