How do I get React-Native working on my Mac? - reactjs

I am unable to get the default "awesomeproject" react-native app working on my new Mac/IOS simulator.
I have installed all the prerequisites on my new mac as listed here:
https://facebook.github.io/react-native/docs/getting-started.html.
After installing everything I run
sudo react-native init awesomeproject.
This seems to work correctly.
I then cd to awesomeproject and run
sudo react-native run-ios
It eventually builds "successfully" and launches the iPhone simulator.
It launches a new terminal for the packager and here it shows loading dependency / graph: done. But it does show a watchman ERROR. See screenshot.
After this, nothing happens. It doesn't launch/install the app on the simulator. The terminal that I ran react-native run-ios is at the command prompt.
I have looked at the troubleshooting guide and other posts, but can't see what I'm missing? I am just trying to do the basic 101 of getting this working on a mac.
I'm running
MacOS: 10.14.5
React-Native version 0.59.9
react-native-cLI: 2.0.1
Xcode 10.2.1
Node: 10.16.0

Either create project again without sudo and run it without sudo or you need to run watchman with sudo permissions. I would suggest creating project again. Please avoid using sudo as much as you can. Thanks

Related

Not able to use a npm start from WSL ( UNC paths are not supported )

I am using WSL 2 on windows 11. When I am trying to use the termainl to create a react project it is giving me this error.
'\\wsl.localhost\Ubuntu\home\nisnym\t\learn'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
and here is the screenshot enter image description here
I also went through this already existing question, but it is not working for me. Question Link
If possible please help me fix this.
To be able to run and create react js apps.
–
node and npm install, I already did both installs enter image description here
Their latest version seems broken.
Even npx -y create-react-app#next does not seem to work with WSL2,
Try with 5.0.0:
npx -y create-react-app#5.0.0 testapp

Create React App Uninstall Global Install Loop

(Windows 10) So, I tried to create a React app, and it asked me to uninstall a global installation of it by running npm uninstall -g create-react-app and the image below is what's returned.
Now, I try and re-run npx create-react-app . inside my terminal in VS Code and it asks me to do the same thing over and over again to uninstall. I have tried restarting my vscode as well, that didn't work.

Expo no longer working? bash: expo: command not found

so I am working on some React Native projects and up until now, Expo has been working great along with Android Studio. However, I think I updated my graphics card drivers a couple of days ago. Now when I try to run "expo start" I receive a "bash: expo: command not found" error.
Any ideas? I keep seeing all this stuff about adding NPM global to my paths but all of those issues/solutions seem to be for Mac. I have no idea how to go about correcting this on a Windows 10 machine. Any thoughts?
expo is not installed on the machine anymore for some reason
since it is an expo project it is straightforward first go to Nodejs webpage
download LTS version NOT THE CURRENT VERSION once node is succesfully installed on the machine it will you can check by opening the command prompt and typing node --version
you should see something like "14.1232."
then run this command npm install -g expo-cli it should install expo again globally
navigate to your project folder and do "expo start" it should work

Unable to load script. Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release

I created a new project with react-native init .
I am using react-native with the following:"react": "16.13.1","react-native": "0.63.2".
When i am trying to run the app with react-native run-android command it shows build successful in the terminal but nothing appears in my metro bundler(I am attaching the image of it) and my emulator shows the 'Unable to load script' issue.
Unable to load script
If I press 'R' to reload the app in node(bundler) it says there is no device attached to it but my emulator is running. I encountered the same problem with personal device also.
metro bundler not running
I also tried by creating the assets folder in android/app/src/main/assets and run the below command:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res.
With this only once the app gets displayed on the emulator and when I make changes in the App.js file and save it there is no change in the emulator.
If I reload the error "Could not connect to the development server" pops up.
could not connect to development server
Even tried the adb reverse and changing 'dev' options to local host and port 8081, but it was not useful. (If there is any specific path where I should try the above steps please mention).
What is that I have done wrong?
Can anyone help please.
P.S.: I am using a windows 10 machine.
Thank you.
"react-native": "0.64.1",
I used other solution but I've resolved this issue in other way.
I resolved it by changing bundleInDebug: true, in project.ext.react in android > app > build.gradle.
project.ext.react = [
bundleInDebug: true,
enableHermes: ***,
]
I am also facing this issue and I try the below method to fix the issue.
for start the npm server use npx react-native start
in another tab npx react-native run-android for run the application.
Many devs have different environment setup and this complicates the solution.
I'm working on Windows with WSL2. Initially, I followed this react-native setup guide with no problems but later encountered this error, not sure why.
After many hours of searching and trying most of the answers from this duplicate question, among others, I had no luck.
Eventually, all I had to do from WSL2 was pass the host option to react-native start in order to connect to the adb server running on Windows.
yarn start --host 127.0.0.1
# or npx react-native start --host 127.0.0.1
I got this issue, I solved with close the app form emulator or if you use android or iphone device you can uninstall the app.
start again npm server use npx react-native start
reinstall app use npx react-native run-android

Moved my React Native project folder to a new machine, how do i get it to run?

I recently cloned my React Native project folder from GitHub to my new/unused Mac. I am now in the root directory and when i run "react-native run-ios" to get the project going and load up the phone simulator, i get -bash: react-native: command not found
Do i need to re-install EVERY single dependency in package.json again (because it seems they're all there in my folders)?
Whats's the minimum in need to get my project up and running again and what commands do i use with my current project. I don't want to have to 'react-native init' an entirely new project!
Thanks
If you haven't done any react-native work on the Mac, then yes, you need to install all the dependencies including the react-native cli. You don't have the cli for react-native installed and you are trying to use it. You need to install react-native cli and NPM and make sure all dependencies are there.

Resources