Error while starting react-native application - javascript

I am not able to run react-native on port 8088. Sometimes it runs and sometimes it doesn't. Last time I restarted the laptop so it ran and now again it isn't running. Is there any permanent solution?

The command should be:
react-native start --port 8088
You can use this command to check the options:
react-native start --help

Related

Node js server auto restart [duplicate]

I am running a node.js application in Windows and I want to make it automatically restart if there is an unhandled exception in the code which causes the application to stop.
I have done some research and I found that a combination "Forever" and "Nodemon" can achieve this goal.
I installed both packages globally on my Windows 10 Device.
npm install forever -g
npm install -g nodemon
I tried using the following command to launch my app:
forever start nodemon --exitcrash app.js
However, I get the following error: "nodemon does not exist"
If try just running "nodemon" the application starts which indicates the Nodemon package is installed however, this will not allow the app to restart after a crash.
Am I doing something wrong? Most advice I find online is only relevant to Linux systems.
If you are already using forever, then you can get rid of nodemon. Instead you can use a combination of forever and cluster module. Simply fork the worker in case of exceptions, and it makes your app more scalable too!
If still nodemon is preferable, maybe try installing it globally using the -g flag
Forever and nodemon achieve 2 completely different objectives
nodemon is used to run your application in development mode, where you are frequently changing code, and need to restart the server .It will not restart your application in case of a crash. more about that later
Forever, on the other hand, is for making your application run as a daemon in production. And auto restart if you have uncaught exceptions.
Historically people have used Forever stand alone, or with upstart scripts, running as a linux service one of the most famous being upstart
Current norm is to use PM2

Stuck on info starting JS server

I have initiated successfully a new react-native project. Then, every time I try to run my newly built project using the command react-native run-android, it gets stucks on info Starting JS server....
Here is the output:
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX".
You can disable it using "--no-jetifier" flag.
Jetifier found 855 file(s) to forward-jetify. Using 4 workers...
info Starting JS server..."
I tried restarting the laptop and switching emulators. I don't know what else to do anymore.
How do I solve the problem?
Kill the automatically popped up metro bundler command prompt
Kill the command terminal which is running react-native run-android
Now Run react-native start This will start your js server
In new command prompt window run react-native run-android
The app came up in 5 mins in an emulator.
Linux:
Go to the terminal and type:
react-native start
and then in OTHER terminal, inside your project folder:
yarn android
or
npm run android
Temporary fix:
REACT_TERMINAL= react-native run-android
in my case with manjaro + xfce4:
REACT_TERMINAL=xfce4-terminal react-native run-android
or puts in your .bashrc:
export REACT_TERMINAL=xfce4-terminal
font: https://github.com/facebook/react-native/issues/26097
I had the same problem. I started a project yesterday and it worked, started a new one today and it didn't work. The problem seems to be "#react-native-community/cli-platform-android". The version that showed up today is 2.8.2 as opposed to 2.7.0 for yesterday's project.
I used:
npm install #react-native-community/cli-platform-android#2.7.0
This is not a optimal solution, but it will get you going.
I had the exact same frustrating issue for a very different reason than mentioned in other answers.
As explained in this SO answer Android adb binds to port 5037 and I installed some program which took this port so adb was hanging silently (why adb! .. say something!)
Commands to test if this your issue cause:
test any adb command and see if it hangs, eg:
adb devices
If it does, then check who is using the port:
sudo lsof -i :5037
In my case(Manjaro OS)
First:
npm start
Then in a separate terminal:
npm run android
The best solution that I constantly find myself using, is going to the application manager on android, then clearing the data of the app. Running the app afterwards goes smoothly without lagging.
Reinstalling android studio with a new emulator or changing the app name in app.json , build.gradle and android manifest.xml solved the issue.

pm2-windows-startup stopped working after Windows reinstallation

I use PM2 module and pm2-windows-startup utility to automatically run Node.js when Windows startups. It was working perfectly during a few months, but recently once I reinstalled my Windows, the utility stopped working.
When I run Node by command promt with
pm2 start myapp.js --watch
I get the message
PM2 is being successfully deamonized
Then if I run the command
pm2-startup install
I get
Successfully added PM2 startup registry entry.
And then if I run
pm2 save
I get
PM2 is being successfully deamonized
Saving current process list...
Nothing to save !!!
But if I restart my computer, the utility doesn't start Node.js
How to resolve the problem?

React native bundling of js failed while running on android

In packager I am getting the following error when I am running the command
react-native run-android
The packager output is:
Loading dependency graph...
Bundling `index.js` [development, non-minified] ░░░░░░░░░░░░░░░░ 0.0% (0/1)Error: watch
ENOSPC
at _errnoException (util.js:1019:11)
at FSWatcher.start (fs.js:1383:19)
at Object.fs.watch (fs.js:1409:11)
at NodeWatcher.watchdir
Any help? thanks in advance.
Try to re run the project and clean the project, cd android and then gradlew clean, and I suggest to run react-native start first, then open a new terminal and run react-native run-android, also i found the troubleshooting case which is quite similar, https://facebook.github.io/react-native/docs/troubleshooting.html#unable-to-start-react-native-package-manager-on-linux hope that helps:)
I followed the steps:
Kill my node server process which is started on 8081 port.
Restarted my complete development environment
And then started my packager(react-native start) as super user.
then executed react-native run-android.
And it is running successfully now.

React Native run on multiple simultaneous Android emulators

I would like to test my app on at least 2 Android emulators simultaneously. I can start 2 emulators but can't seem to find how to react-native run-android my app on 2 emulators with ADB. If possible I would also like to be able to run a react-native log-android on each one while testing my app.
Is there a way to do so ?
You can only do it on different ports. Because one port, one listener :/
Solve:
react-native start --port 9988
./emulator -port 9988 -avd devicename1
react-native start --port 9999
./emulator -port 9999 -avd devicename2
Edit2:
Before running the emulator, You can write in the terminal and then run it:
function emulator { cd "$(dirname "$(which emulator)")" && ./emulator "$#"; }
First emulator is react .
emulator -port 9988 #react
react-native run-android ( automaticaly detect emulator )
Second emulator is r .
emulator -port 8081 #r
react-native run-android (automaticaly detect emulator )
In order to run your react application on multiple emulators, just start 2 emulators as usual and then use the command react-native run-android.
You can even specify any port number as react-native run-android --port 8084 if you want. Your app will start on both the emulators simultaneously. :)
Have a look here
The accepted answer by #Burhan Yılmaz did NOT work for me. This is probably due to new updates and development in the relevant software. The following steps demonstrate what worked for me.
Start the 1st emulator, e.g.
emulator -avd Nexus_S_API_28
Start the 2nd emulator, e.g.
emulator -avd Nexus_S_API_28_2
Start React-Native in the same way, which you would usually use (without specifying any ports.)
react-native run-android
This sends a copy of the code to both devices. However, each device runs its copy in isolation from the other device.
Environment Details:
MS Windows 10
Android SDK 29.0.2
React-Native: 0.61.2
Using Genymotion, you just have to start 2 instances and start them as if there was only one (react-native run-android to install the app and react-native start)

Categories

Resources