Failed to start Watchman watch mode - react-native

I am developing a React Native app. My code is error free, but it is facing build problems. I get an error in the Metro Bundler when I execute the command react-native run-android. The error says:
UnhandledPromiseRejectionWarning: Failed to start watch mode.
I also tried adding Watchman to node_modules using the command $yarn add watchman.
I get a prompt that it is deprecated.
How should I solve the error?
My package.json contains the following:
"dependencies": {
"expo": "^25.0.0",
"native-base": "^2.3.7",
"react": "16.2.0",
"react-native": "0.52.0",
"react-native-vector-icons": "^4.5.0",
"react-navigation": "^1.0.0-beta.27",
"watchman": "^1.0.0"
}
"devDependencies": {
"babel-jest": "22.1.0",
"babel-preset-react-native": "4.0.0",
"jest": "22.1.3",
"react-test-renderer": "16.2.0"
}

To have watchman in windows do the following:
(1)Download watchman zip file from the link here
(2) Unzip the folder
(3) Place the watchman.exe file in the folder that is registered in the PATH (environment variable) (Eg: Place the watchman.exe file in C:/ProgramFiles/ and make sure the PATH = 'C:/ProgramFiles')
Done! You would never face this error again!

I have also faced the same issue.Then I have
Deleted the node modules and installed them again by using npm install.
Then clean gradle by '.\gradlew'
Then run the app by 'npx react-native run-android'.
The above steps helped me to resolve the error.

You have to install watchman using brew:
brew install watchman

in windows npm install watchman

I tried the following:
Restarting my system
Deleting npm/yarn cache.
Most of the times the above methods worked but not always. So, here's one-time permanent solution (for Windows)
Download the Watchman v2021.01.11
Unzip, Rename the folder "Watchman" and paste the C:/Program Files.
Open the folder and copy the location of bin folder (would be C:/Program Files/Watchman/bin)
Go to Environment variables, search of PATH variable and append the copied location of bin

same issue I got on metro Android
I tried the following Steps:-
1.npx react-native start --reset-cache
2.cd android && ./gradlew clean && cd..
3.npx react-native run-android
In mac, I used
watchman watch-del-all
on Terminal
then I re-run the XCode. It's working

Failed to start Watchman watch mode (Windows)
I tried a lot to fixed the issue and at last, I restart my windows now it's working.

Related

React Native Android Project Not Found

I am getting this error.
error Android project not found. Are you sure this is a React Native project? If your Android files are located in a non-standard location (e.g. not inside 'android' folder), consider setting `project.android.sourceDir` option to point to a new location.
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
There is no solution on this link.
"dependencies": {
"react": "17.0.2",
"react-native": "0.68.2"
}
```
Package.json file
Hi i have solved with 3 steps.
Clear node_modules
add this to package.json
"resolutions": {
"glob": "7.2.0" }
And reinstall with npm install
If this is not work please install glob with npm i glob#7.2.0
you can fix it without reinstalling, just go into the node_modules folder, find glob, and open the common.js file.
in line 114 you will find options.allowWindowsEscape = true, change it to false and it will work perfectly!
You can install glob npm i glob
Its works for me.

npm start command gives error in react native

I have been using /programming react native app since last 2 months.
Always it used to work fine , I could code and run the simulator on my iphone . The environment details are as follows:
EXPO --version 3.1.2 , npm -v 6.9.0, node -v12.4.0
Suddenly, yesterday when I started the project by command 'expo start' it did not start, got a message expo is not installed. Hence I installed expo cli.
Now I typed the command 'expo start', however it gives error
It opens the Metro builder but stops with error
I am unable to start the project and continue coding the app
I tried following troubleshooting :
removed 'node_modules' folder , re-installed 'npm install'
however the same issue persists.
Expected:
The project should start , I should be able to run the simulator in phone
Actual:
The project did not start with 'expo start'
Microsoft Windows [Version 10.0.17134.1006]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\Jituni>cd C:\Users\Jituni\bholmentorworld
C:\Users\Jituni\bholmentorworld>expo start
Starting project at C:\Users\Jituni\bholmentorworld
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
Error: Can't find react-native in package.json dependencies
Error: React Native is not installed. Please run `npm install` in your project directory.
Couldn't start project. Please fix the errors and restart the project.
Set EXPO_DEBUG=true in your env to view the stack trace.
this is the dependencies.
{
"dependencies": {
"eslint": "^6.2.1",
"expo": "^33.0.0",
"firebase": "^6.4.0",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native-gesture-handler": "^1.2.2",
"react-native-reanimated": "^1.0.1",
"react-native-web": "^0.11.4",
"react-navigation": "^3.11.1"
}
}
you hadn't installed the react-native in your dependencies.
SOLUTION
you should make the new project with expo-cli.
FIRST, run this command -> expo init projectname
at this step, select the blank project selection.
then you can see the generated project.
SECOND, merge the dependencies. and then run npm install or yarn install.
LAST, run react-native project with npm start or yarn start.

React Native App with Expo - QR code not loading

I'm following this tutorial:
https://blog.expo.io/building-a-react-native-app-using-expo-and-typescript-part-1-a81b6970bb82
yarn global add create-react-native-app
create-react-native-app my-app-name
cd my-app-name
yarn start
I am on the same network as my phone (Android). No VPN. I am in the root folder of my app. It says Loading dependency graph, done. so I know it's running.
Firewall is also off for this as well and this is not a timeout error.
When I scan the QR code:
Something went wrong. Could not load exp://10.0.0.21:19000.
What could be my issue?
EDIT
New error: Uncaught Error: java.net.ConnectException: Failed to connect to /10.0.0.21.19000
Try opening the debugger in chrome and then select tunnel if your device and the development pc are not connected to the same server.
Try the Enter URL manually option
First make sure you are on the same wifi ( computer || laptop and mobile device)
Second open cmd and run command ipconfig their you will get IPv4 Address copy it
Go to your expo go app tap on Enter URL manually
Enter exp://your_IPv4_Address:19000 ( Example -- exp://192.168.1.38:19000 )
Connect now -- It should work
In my case, I used tunnel and there was a problem with the sdk version - I have 39.0.0 and I should use only 36, 37 or 38 - that is the message that i have got from expo, so all I did is to get into the app.json file, and add the following line in expo (or just change it if it already exist):
"sdkVersion": "38.0.0"
and it should look like:
"expo": {
"name": "DoneWithIt",
"slug": "DoneWithIt",
"sdkVersion": "38.0.0",
"version": "1.0.0",
....
....
}
In the package.json file in dependencies, change the version to 38.0.0 in "expo" and "react-native" :
"dependencies": {
"expo": "~38.0.0",
"expo-status-bar": "~1.0.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-
38.0.0.tar.gz",
"react-native-web": "~0.13.12"
}
then run:
cd yourAppName
npm start
and it will be loaded on your phone.
you can watch it from here:
https://www.youtube.com/watch?v=eS8VULijAZ4
In this video he uses 32.0.0 so be aware to the updated version (in my case 38.0.0 was good for 09/2020)
Just delete the node_modules folder from your application and then run npm install to get the dependencies.
Now run expo start or npm start, the QR code will load now.
On node v12.18. In the package.json downgrade expo and react-native connector. 38 works instead of 40.
"expo": "~38.0.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.0.tar.gz",
Then remove node_modules and reinstall them
rm -rf node_modules
npm install
then run again :
npm start
QR should work this time
I had this problem after and expo update. Instead of running
npm/yarn start
(executes expo start --dev-client)
Try
npm run run
(executes expo start)
run the command
expo start --tunnel

Requiring unknown module "11" error on iOS simulator

When I run the react native project with react-native run-ios.It shows the following error on my iOS simulator.On my android simulator, it is totally ok.I have deleted node module and reinstalled.But the error is still there.I don't want to entirely delete my ios/build folder since I have manually added library dependencies in there and that third party libraries were working properly in my react native project.Can someone help me with this?
Error Message
Requiring unknown module "11".If you are sure the module is there, try
restarting Metro Bundler.You may also want to run yarn or npm install(
depending on your environment ).
package.json
{
"name": "AwwsomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-navigation": "^1.1.473",
"react-native-vector-icons": "^4.6.0"
},
"devDependencies": {
"babel-jest": "23.2.0",
"babel-preset-react-native": "4.0.0",
"jest": "23.2.0",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}
Restarting packager fixed my issue.
I fixed the issue with the instructions from the following page:
https://facebook.github.io/react-native/docs/troubleshooting#content
Basically it asks you to terminate the processes running on a specific port.
Run the following command to find the id for the process that is listening on port 8081:
$ sudo lsof -i :8081
Then run the following to terminate the process:
$ kill -9 <PID>
I just killed all node processes
killall node
🙌 and launched again
I had the same problem. Running npm install or yarn install should fix the issue.
I had the same problem while working with my react native app and expo. Same screen with 'Requiring Unknown Module 1".
This is how I fixed it:
I closed Expo
I closed the Metro bundler on my local host
I closed the packager on my terminal with Ctlr + C
I restarted with npm start
I relaunched the project on Expo.
It worked for me.
I had this issue on Android (React-Native-CLI).
Terminating the application and restarting metro server absolutely solved the issue.
yarn react-native start
Using yarn, I did the following (for Android emulation):
From root directory in your project:
cd android
./gradlew clean
cd ..
yarn start --reset-cache
yarn android
Looks like node and the application inside simulator hangs sometimes. I encountered this several times on macOS / iOS.
yarn install did not help.
restarting simulation with expo run:ios / yarn start / yarn ios did not help.
What helped was killall node and killall <your_mobile_app_name>.
npm run ios fixed for me after npm start

failed building javascript bundle about #expo/vector-icons

I use react-native-app and expo to build a project called UdaciFitness, but I come across some problems when I use 'import '#expo/vector-icon''
the error message in windows CMD is
17:41:21: Unable to resolve #expo/vector-icons" from "./C:\\Users\\acer\\WebstormProjects\\UdaciFitness\\node_modules\\expo\\src\\Icon.js"
17:41:21: Failed building JavaScript bundle
18:16:28: Unable to resolve #expo/vector-icons" from "./C:\\Users\\acer\\WebstormProjects\\UdaciFitness\\node_modules\\expo\\src\\Icon.js"
here is part of my package.json:
"dependencies": {
"expo": "^25.0.0",
"react": "16.2.0",
"react-native": "0.52.0"
}
You need to install #expo/vector-icons. Run yarn add #expo/vector-icons in your project directory to add it to package.json and install the package. Then restart the Expo tools and load your project again.