'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.
Solution 1:[1]
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.
Added this to the start script in package.json:
"scripts": { "start": "PORT=3001 react-scripts --max_old_space_size=8128 start", ... }
Closed all my chrome browsers (they take pretty much memory)
- 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 :)
Solution 2:[2]
Check This Tow points
- Run npm install command before you start the server.
Then also it is not running , please try the second command
- Remove the node modules and run npm install once again.
If these two points didn't work , Please provide the screenshot for further analysis.
Solution 3:[3]
First time you run the command it takes about 5 minutes before the page loads.
Solution 4:[4]
I created my react app by create-react-app too.
I've tried all the method mentioned above. But it didn't work for me.
Then I accidentally found out if you have unused import
or any unused statements. You will stuck.
My react version is 17.0.1
.
Solution 5:[5]
Make sure that your dependencies in package.json
includes the following:
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0"
And scripts to be:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
Once you ensure that, you can follow the following steps:
1. npm install
2. npm run build
3. npm start
Hope will works for you.
Solution 6:[6]
the same problem as i met; npm start
but got stuck like you on the “Starting the development server” message.
after i trying the following ways but didn't worked:
- npm install
- npm run build
- npm start
it seems not the version matter.
finally, i recheck my code, and found the mistake that's the cause of development server fail to start:
useEffect()
this is the hook incorrect using, maybe i forgot to finish it; then i fixed it, and npm run start, it worked, server started successfully.
Solution 7:[7]
For me, the problem was the name of the parent directory. For some reason it choked on "#" when I tried to install into a directory named "#TEMP". Switched to another directory with success.
This has previously worked on my old MBP i9, I'm now on a MBP M1 Monterey 12.2.1.
Solution 8:[8]
Finally solved this. For me the issue lay in my webpack configuration. I had a webpack alias in there whose alias name was the same as the name of my npm package.
i.e.
My package.json
had the following at top.
"name": "@mycompany/react-common-components"
Within my webpack.config.js
I had
alias: {
'@mycompany/react-common-components': path.resolve(__dirname, '../src/components')
},
Once I changed the webpack alias to the following everything worked fine
alias: {
'react-common-components': path.resolve(__dirname, '../src/components')
},
Solution 9:[9]
I believe you may have some issues with Node and npm. I would recommend checking the versions first - you’ll need to have Node >= 8.10 and npm >= 5.6 on your machine, and update if needed. It could worth trying to reinstall node.
Checking into node logs could provide some clues on your issue (more information on how to log here)
Solution 10:[10]
I was also having the same issue. Try installing a previous version of react-scripts.
npm install [email protected]
Hope this helps!
Solution 11:[11]
had the same issue, I had to build it first
npm build
then
npm start
I was running react on my Mac and had to give permission for the terminal to interact with chrome before it worked.
Solution 12:[12]
For me the issue was that I had .css
files.
I renamed my css files to .scss
and it works.
For some reason create-react-app chokes on CSS files for me.
Weird.
Solution 13:[13]
My team also faced this same issue but we managed to solve it.
Run
npm install
to update packagesthen run
npm audit fix
to fix vulnerabilitiesFinally close all browser tab to free up RAM. I have seen node processes take a significant amount of memory.
Run
npm start
and the development server spins up within a minute or two.
NOTE
Make sure that your dependencies in package.json
includes the following:
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0"
And scripts to be:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
Once you ensure that, you can follow the steps given above.
Solution 14:[14]
I ran into this issue. In my case, there was an .eslintcache
file that had incorrect information in it, and was causing an issue. Simply deleting the file solved it for me.
Solution 15:[15]
For me, it was because of using StrictMode
, the server starts, but the app keeps loading for a long period.
Solution 16:[16]
This is my react version: "react": "^17.0.2", "react-dom": "^17.0.2", "react-scripts": "4.0.3",
My node version is 12.18.1, and it didn't work. I try to change the version to 14.15.0, and then run success.
Solution 17:[17]
This is my case. In my react app project I configured eslint with
https://github.com/prettier/eslint-plugin-prettier
After removing minimized source file(in my case, mapbox-gl.js) from the source tree, everything works.
Solution 18:[18]
Here are tow points checked:
- Remove
package.lock
andnode_modules
, re-install:npm i
. - Check the node version. Maybe you currently use version is 12.0.0, but this project limited 14.0.0.
Solution 19:[19]
I had similar issue. I just opened chrome to check if it's actually running on there (chrome is my default browser for vs code) and npm could then run the next step after that. So try opening the browser if you're stuck on "starting dev...."
Solution 20:[20]
This is not so much an answer as how to fix the problem in all cases since I think there are likely multiple things that affect this.
Following the ticket here https://github.com/facebook/create-react-app/issues/12090 allowed me to track down the issue to being something to do with the chunks within the bundles having the same file name.
Solution 21:[21]
I was getting timeouts on yarn install
and after that worked, getting stuck on Starting development server...
which it never did before on this computer.
It may have to do that I am not in the USA, so I set my VPN to Los Angeles and deleted the yarn lock file and the node_modules directory, re-ran yarn install
and ran yarn start
and everything worked!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow