React app stuck on "Starting the development server" - reactjs

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.

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 :)

First time you run the command it takes about 5 minutes before the page loads.

Check these two points
Run npm install command before you start the server.
Then if it is still 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 a screenshot for further analysis.

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.

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.

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.

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.

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.

FWIW, I restarted my macbook, changed nothing and everything worked again 🤦‍♂️🤣

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')
},

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)

I was also having the same issue. Try installing a previous version of react-scripts.
npm install react-scripts#2.1.8
Hope this helps!

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.

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.

My team also faced this same issue but we managed to solve it.
Run npm install to update packages
then run npm audit fix to fix vulnerabilities
Finally 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.

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.

For me, it was because of using StrictMode, the server starts, but the app keeps loading for a long period.

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.

Here are tow points checked:
Remove package.lock and node_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.

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

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.

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!

this error can occur because of multiple reasons , my particular case (as shown in the picture attached) occurred abruptly when I was installing splide and styled-components probably because of some vulnerabilities
My error was resolved by running
npm audit fix --force

Related

--openssl-legacy-provider with React App, will it cause build/deployment issues down the road?

World!
So as the title says, I have copied a template for a project, it has a bunch of heroku/pg/middleware configs already set up for me.
I have run into the 'ERR_OSSL_EVP_UNSUPPORTED' error when attempting to NPM START.
I know I can downgrade to v16, I just passed the package.json
"scripts": {
"start": "PORT=4000 react-scripts --openssl-legacy-provider start",
"build": "react-scripts --openssl-legacy-provider build",
And this fixed the issue and lets me start normally while still using v18.
I'm worried that down the road this may cause issues during deployment, does anyone have experience with this or a better fix than just the legacy ssl workaround?
Or would one recommend to start fresh and add all the configs myself and not risk it?
I think what could potentially happen is that when node 18 comes to end of life and it's time to update to the latest, you might find that they removed the --openssl-legacy-provider option, and you'll have to upgrade whatever package is using legacy openssl.
Since this is a case of "this might be needed later", and it likely will be no more work to do it later than it is now, I think I would say that you can proceed as-is, and if some day down the road you need to address the legacy OpenSSl dependency, you can do so then.

issues with npm start

Trying to run a React project I haven't touched in a week or so. When I run 'npm start' the project doesn't show up in my browser automatically anymore. My terminal says that it's being served locally. When I pasted in the address, it didn't show up and I received a 'not found' error . After about 5 min I tried again, and now the project shows up on localhost:5000. I am curious though as to why 'npm start' isn't automated like it should be with React. I tried making changes to my project, and the app in my browser isn't responding to any changes I'm making, even with a hard refresh. So far I've tried deleting node_modules and re-installing npm. I haven't found a thread on npm start that addresses this particular issue, so any advice is appreciated.
Okay, figured it out. For some reason the script for running in my
package.json changed to
"start": "serve -s build" I changed it to "react-scripts start" and that seemed to fix the problem. Not really sure what made it change in the first place.

react native downloading javascript bundle 100% stuck

when I am trying to execute npm start it works fine, but when i try to run my application by expo the process goes till 100% and after that nothing happens. I am not getting what is exact issue over there. I am having following things in package.json.... please help me to resolve this issue.
{
"name": "ProMeeting",
"version": "0.1.0",
"private": true,
"devDependencies": {
"jest-expo": "~29.0.0",
"react-native-scripts": "^1.14.0",
"react-test-renderer": "16.3.1"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "jest"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"#babel/preset-react": "^7.0.0-beta.56",
"expo": "^29.0.0",
"firebase": "^5.3.1",
"native-base": "^2.7.2",
"react": "16.3.1",
"react-native": "^0.55.4",
"react-native-firebase": "^4.3.8",
"react-native-vector-icons": "^5.0.0",
"react-navigation": "^2.11.2"
}
}
Screenshot added for illustration purpose
It seems there are multiple reasons why this could happen. I tried to run other apps on my simulator, restarted my simulator and even tried to delete the build folders and rebuild from scratch, but none of these approaches solved the issue.
What finally worked was restarting the React Native Debugger that I had on in the background the entire time.
You can also check the Network tab of React Native Debugger if you've enabled Offline throttling. Disabling it should also solve the issue in some cases.
In my case this always happened when I remote JS debugging was turned on. The JS bundle would load to 100%, but then the app was stuck. React Native Debugger could not connect, with the error message Another debugger is already connected.
After trying all kinds of things (cache resets, restarting Metro builder, restarting simulator) without any luck, I remembered that the only "other debugger" I had ever used were the Chrome Devtools, so I quit Chrome, and immediately everything was working again.
Turns out, even though I had closed the Chrome tab where I had been debugging the app, some background process in Chrome was still attached as a debugger to the app (also after reboots of the simulator). Then it hit some kind of breakpoint or exception on startup, so it paused, and all I could see was the Downloading Javascript bundle 100% message.
This is how I resolved the issue in Mac.
My screen was stuck at Downloading javascript bundle 100%
Select Simulator, Press (Command + D) in Mac, the simulator will display the set of options.
The Application will now load
In my case, my code worked in Android, but not in iOS simulator.
SplashScreen.preventAutoHide(); was the problem.
I called the method twice, App.js and Main.js, respectively.
After removing it in the App.js, it worked.
(I think restarting the React Native Debugger helped as well)
react-native-firebase often cause same issue.
below is official integration guide of react-native-firebase.
https://rnfirebase.io/docs/v5.x.x/installation/ios
B) At the beginning of the didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method add the following line:
[FIRApp configure];
"It is recommended to add the line within the method BEFORE creating the RCTRootView. Otherwise the initialization can occur after already being required in your JavaScript code - leading to app not initialised exceptions."
Do you have GoogleService-Info.plist?
Did you pod install?
Did you Hardware > Erase all Contents and settings in simulator?
I also stuck at the same problem and did every possible thing but it not worked, I revert every change but still the issue is there..
I created my own solution and it works perfectly for me, maybe it might help someone, you can try it with Apple and Android too
Update expo-cli and react-native with npm update -g expo-cli and npm update -g react-native
Uninstall expo app on emulator or device and reinstall it
Create new project with expo init project_name (use your original project name, rename the previous for backup).
Try to run this new blank app in your expo app, it should run properly.
Now install every dependency from non working package.json one by one or in bulk but without giving version using command expo install package_name (Manually because it might be possible because of version conflict).
Now add your old project files and directories including app.json and App.js to this new project.
Run your project again with expo start -c command.
And here you go with your working project!
Happy Coding!!!
As of January 2021, your node version may be one of the causes of this problem.
Check your node version using node -v and if the version is 15.x.x, try downgrading the version to 14.15.1:
$ npm install -g n
$ n 14.15.1
In my case, When i was tried with physical device then try to install in simulator. Then its got stuck like it. I solved the problem after stopped the debugger. For that use below steps.
Android:
Go to settings in mobile >> Installed Apps >> choose your app and click on clear Data.
uninstall your existing app and try to install .
IoS:
Uninstall the exist app and try to install as new.
Shake your device and stop debug and try again to install.
Well in my case I removed a for loop that I had in my code and it was enough to fix this issue. Apparently my react app was crashing everytime it run that loop.
in my case ;
I added a new package ( #khanshamshad32/carousel ) v1.0.1 . i guess package has problems and my expo on real device stuck %100.. and im going to delete all of items package.
1- from package.json (relative instance)
2- from package-lock.json (relative instance)
3- from "package name" folder of node_modules
and it did work
You should try setting up a new react-native project and transfer your files to the new project and then try running it again, this issue occurs when build files are missing
well this post is old but lets go,
how I solved this problem for myself:
> install yarn
> run: yarn remove react-native
> run: yarn add react-native
> run: react-native run-android

Create react app, reload not working

I just started coding in React using create-react-app. In the documentation it's said
The page will reload if you make edits.
I don't know which module is responsible for auto reload (webpack or react-hot-reloader?) but it's not working. I edited file using different editors (Sublime, VIM, ..) but it seems problem is for something else. Any advice how to debug it?
After too many searches I found Webpack watch uses inotify to observe file changes and in ubuntu it's set to a low value. a quick fix:
sudo -i
echo 1048576 > /proc/sys/fs/inotify/max_user_watches
exit
If you want change it permanently (from Ronald answer):
echo "fs.inotify.max_user_watches=524288" >> /etc/sysctl.conf
sudo sysctl -p
You may also need to add a .env file in the root directory of your project with this line "FAST_REFRESH=false" as noted in create react app docs.
echo "FAST_REFRESH=false\n" | cat > .env
Year 2021
I had this issue in react ^17.0.2 I fixed it by adding a .env file and setting FAST_REFRESH=false.
Just create a .env file in the root directory of your project and add FAST_REFRESH=false in the file.
For Ubuntu users, run this in the terminal:
sudo gedit /etc/sysctl.conf
Scroll to the bottom and paste:
fs.inotify.max_user_watches=524288
Save and close the editor, then run this:
sudo sysctl -p
To check your success:
cat /proc/sys/fs/inotify/max_user_watches
This should return 524288
by apsrcreatix
Ref: https://github.com/flathub/com.visualstudio.code/issues/29#issuecomment-477126012
I had the same problem in Ubuntu.
The problem was resolved by deleting node_modules and then run
yarn install // or npm install
I hope to save someone else the same pain I experienced.
I'm using Windows 10 and Ubuntu 20.04 WSL, with nvm to manage node/npm.
I had to:
Use Node v16.14.2 in nvm (which also uses npm 8.5.0)
Change react-scripts from "react-scripts": "5.0.0" to "react-scripts": "4.0.3" in my package.json file
Change my package.json start script to
"start": "CHOKIDAR_USEPOLLING=true react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
I then ran npm install to update react scripts and restarted the bash terminal
I also followed Ronald Araújo's advice in his answer for good measure.
5 hours later, it's finally working!
Good luck everyone!
There actually is solution to get Fast refresh working.
Use this patch https://github.com/facebook/create-react-app/pull/11105/files
From #pmmmwh
Use https://www.npmjs.com/package/patch-package for editing your dependencies.
install patch-package (via npm or yarn into your project)
npm: npm i patch-package
yarn: yarn add patch-package postinstall-postinstall
Edit package.json and add postinstall script
"scripts": {
+ "postinstall": "patch-package"
}
Edit file YOUR_PROJECT/node_modules/react-dev-utils/webpackHotDevClient.js - with changes introduced in github pull request above
run npx patch-package react-dev-utils
commit changes created by this script (e.q. ./patches/react-dev-utils+11.0.4.patch)
run your app, now it will refresh on changes
Or wait for new release of react-dev-utils (it is not yet released, last version #11.0.3 doesn't contain this update).
My hot reload in Create React app broke due to updating some packages (probably because of typescript). I had to solve it without the ejecting of CRA.
I managed to fix it by upgrading to version 16.10 of these packages:
"react": "^16.10.0",
"react-dom": "^16.10.0"
And it worked just fine!
My code in index.tsx:
...
const isDev = process.env.NODE_ENV === 'development'
const rootEl = document.getElementById('root')
ReactDOM.render(<App />, rootEl)
if (isDev && module.hot) {
module.hot.accept('screens/App', () => {
ReactDOM.render(<App />, rootEl)
})
}
Hint:
First try just this code (maybe you are setting wrong path)
if (module.hot) {
module.hot.accept()
}
If this start working then you want to specify the path in order to make hot loading more effective (less bubbling = shorter loading)
Try adding CHOKIDAR_USEPOLLING=true in a .env file.
If the React webpage is not reloading upon saving changes, try adding this line to the App.js file:
import React from 'react';
After create-react-app,I change my project's name.This is one of reasons which make reload not working.Then I create-react-app again,reload is working now.

React tutorial - how do I start the node server for a reactJs application?

I'm just starting the react.js tutorial, I've downloaded the files and then it mentions:
"Follow your progress by opening http://localhost:3000 in your browser (after starting the server). "
I know this may sound stupid, (bear with me since I'm a beginner with React) but how do I start the server in this instance?
Thanks.
Marc
Pretty solid chance it's npm start from the project root.
Properly packaged modules will have some node scripts configured in package.json. It's customary to use start as the script to run the dev environment, though some might use build, dev, or other names.
Here's official installation process: link, and officially recommended tutorials
# install react cli
npm install -g create-react-app
# create app
create-react-app my-react-app-name
# go to project folder
cd my-react-app-name
# install dependencies
npm install
# start live server
npm start
output:
$ You can now view my-react-app-name in the browser.
$ Local: http://localhost:3000/
$ On Your Network: http://192.168.0.105:3000/
$ Note that the development build is not optimized.
$ To create a production build, use npm build.
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
All the above commands are equivalent but people prefer the third one as it is the shortest to type on keyboard.
The start parameter in these commands maps to the start key present under scripts configuration present in package.json file of any ReactJS application. Here is a sample package.json file of my hello-world application:
{
"name": "hello-world",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2"
},
"devDependencies": {
"react-scripts": "0.9.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
You can see that react-scripts start is written in front of start key. So react-scripts start command will get fired when we run any of the three commands which I had enlisted in the beginning e.g. npm start.
I used Node to run the server. The steps I followed are:
I downloaded the zip package from the Running a server section
here
I had the link open: http://localhost:3000/
I opened up Node.js Command Prompt and navigated to the downloaded
zip project. From Node example here:
Just type the commands in the example:
First npm install and then
node server.js.
See the screen shot below:
When I refresh the localhost web page I see the following:
Sounds like you're following the official React tutorial, in which case the instructions to start the various included server implementations are here.

Resources