When I run a react-native application and metro start automatically with this error but if I start metro server manually with npx react-native start it works.
Related
After adding the new files from a different folder I got this error:
ReferenceError: Can't find variable: W4r
ERROR Invariant Violation: "main" has not been registered. This can happen if:
Metro (the local dev server) is running from the wrong folder. Check if Metro is running, stop it, and restart it in the current project.
A module failed to load due to an error and AppRegistry.registerComponent wasn't called.
I did not find the "W4r" in anywhere in my code
Remove node_modules folder
Install dependencies (npm i)
Close android emulator & close metro window
cd android && gradlew clean
npx react-native start --reset-cache
After "Metro" opens, close it
npm run android
I try this when my env no respond, hope its help you.
I been trying to create a sample react-native sample app that would work on both windows and mac from the same project.
I first ran npx react-native-windows-init which worked just fine and excecuted the windows program.
but after running npx react-native-macos-init on the same project, I can't build the windows react-native version any more. I get
Error: TypeError: Cannot read properties of undefined (reading 'configurations'). (7ms)
× Autolinking failed. Cannot read properties of undefined (reading 'configurations')
Command failed. Re-run the command with --logging for more information.
I created numerous blank projects and installed each one individually. Clean the node_modules and then ran npx react-native run-windows
My React-Native(0.68.1) project runs properly on my emulator when using npx react-native run-android command and everything works fine with the metro bundler instance created by this command.
Only when I run project from android studio (2021.3.1 Patch 1) , app is build successfully and installed on emulator, but cannot connect to metro bundler (which I separately run using npx react-native start command).
I wanted to try and update the debug server & port as mentioned in other similar questions , but I cannot access the debug app menu even after dismissing the error (menu doesn't show when ipress the shortcut)
Issue also occurs on build installed on emulator via npx react-native run-android when I close the app and metro bundler created by the command and start a separate metro bundler. In this case but I am able to enter settings menu and enter "debug server and port " to 10.0.2.2:8081 and app connects to metro.
I am using mac mini m1.
To fix this issue
first of all, start your emulator and run adb reverse tcp:8081 tcp:8081 this command on the terminal and then run npx react-native start and then run your project in the android studio and it will automatically link your app to that bundle
I was able to build app using expo build:android previously. However, after upgrading to latest expo version I get following error:
connect ECONNREFUSED 127.0.0.1:19001
Set EXPO_DEBUG=true in your env to view the stack trace.
I also see the following lines in the log:
Publishing to channel 'default'...
Building iOS bundle
I don't added ios to my app.json, I only need to build an android apk. To do that I use expo build:android -t app-bundle
I also removed package-lock.json and node_modules and run npm install, but I get the same error.
I run expo start on another cmd and then run expo build:android -t app-bundle still get same error
Also when I clear expo cache, see the following log:
Restarting Metro Bundler...
Starting Metro Bundler on port 19001.
Couldn't adb reverse: adb.exe: error: Invalid source port: 'undefined'
I had faced same issue myself and found the solution. Expo is looking for localhost:19001 which is not running. Just follow following steps and it should work as expected:
Run expo start no terminal and once it opens up the
browser where you will find this line written Starting Metro
Bundler on port 19001.
Now open another terminal instance and run expo build:android.
I am developing react native app using expo cli. I installed expo-cli using yarn with yarn global add expo-cli .
I created my project using expo init appname.
everything looks good, my project is created but when ever I try to start my project, my computer is getting stuck at:
starting metro bundler on port 19001