Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React app stuck on "Starting the development server"

I have a react app created by create-react-app. After running npm start (the start script is present in package.json as "start": "react-scripts start") the console says Starting the development server as usual and fires up the browser. But after this both the console and the browser do absolutely nothing indefinitely. No error or output. It simply does nothing.

like image 733
kenneth-rebello Avatar asked Nov 07 '19 06:11

kenneth-rebello


People also ask

How do I start the dev server in react?

You can run any one of the below mentioned commands to start the node server for your ReactJS application: npm run-script start. npm run start. npm start.

Why does react take so long to start?

The major cause for this issue is adding too many components into a single bundle file, so the loading of that bundle file might take more time. To avoid this kind of issue, we need to structure our components in an optimized way.

How do you fix create react app not working?

If you really need create-react-app , you might need to reinstall Node and reconfigure your dependencies to ensure you have a fresh start with Node, npm, npx, and the like. This is a good resource for updating and reinstalling Node.

Why npm start not working?

Check the ignore-script config If you see the start script is present inside your package. json file but still can't run the script, you need to check the console output. If there's no output at all, then you may have the ignore-scripts npm configuration set to true .


2 Answers

I have something similar happening to me.

I have a react project that I want to convert to Typescript and I started as you noted with the "create-react-app", added all my files and hoped for the best - but got stuck like you on the “Starting the development server” message.

I have an 8GB Ram with Windows 10 and once I used the default "npm start" for the first time I've seen the node process uses a lot of memory - So I tried to give it more and at the same time I tired to change the port react uses.

  1. Added this to the start script in package.json:

    "scripts": { "start": "PORT=3001 react-scripts --max_old_space_size=8128 start", ... }

  2. Closed all my chrome browsers (they take pretty much memory)

  3. And gave it around 1 minute to run

After 1 minute it started working and from that point it just starts quickly and not uses as much memory and not depended on the port I choose

In my case - I guess the first time you run "npm start" on the React Typescript project it probably index the files (or does something similar - I'm not sure and probably need to read about it - I'm new to typescript) which take a lot of memory.

In your case - It might be something similar

Hope it helps :)

like image 82
Sharon Lifshits Avatar answered Sep 18 '22 08:09

Sharon Lifshits


Check This Tow points

  1. Run npm install command before you start the server.

Then also it is not running , please try the second command

  1. Remove the node modules and run npm install once again.

If these two points didn't work , Please provide the screenshot for further analysis.

like image 25
Jerrin stephen Avatar answered Sep 21 '22 08:09

Jerrin stephen