Cannot start react-native server - react-native

I have React-native project. When I want to start it, I run npm start or yarn start, and I get this:
$ yarn startyarn run v1.7.0
$ react-native-scripts start
11:36:37: Starting packager...
***ERROR STARTING PACKAGER***
No issue with doctor-watchman-version
No issue with doctor-problem-checking-watchman-version
No issue with doctor-both-app-and-exp-json
No issue with doctor-schema-validation
No issue with doctor-validate-asset-fields
No issue with doctor-schema-validation-exception
No issue with doctor-unversioned
No issue with doctor-versions-endpoint-failed
No issue with doctor-invalid-sdk-version
No issue with doctor-node-modules-missing
No issue with doctor-react-native-not-installed
Starting Metro Bundler on port 19001.
Metro Bundler ready.
jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
Usually this happens when watchman isn't running. Create an empty `.watchmanconfig` file in your project's root folder or initialize a git or hg repository in your project.
Error: Watchman error: too many pending cache jobs. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.html.
If I uninstall wathcman Packeger get stucked.
Creating .watchmanconfig file, also didn't help.
(Linux Mint OS)
Hours of searching. I have not found a solution yet :(

Try this:
npm r -g watchman
brew update && brew upgrade
brew install watchman

watchman shutdown-server
This command from this GitHub issue worked for me

Try this:
$ npm install
If you are using visual studio, in the bottom of the view there is button to restart. click that and run

Related

Watchman Version Showing 0.0.0. Preventing npm start on React Native App

I am trying to develop a react native application on MacOS, but I have been running into issues with installing watchman onto the machine. I have been running the command brew install watchman and whenever I enter the command watchman version the output displays version: 0.0.0. However, directly after running the first installation command over again, I see Warning: watchman 2022.06.06.00 is already installed and up-to-date which is really confusing me.
I have tried various different troubleshooting techniques such as uninstalling and reinstalling watchman, instead of using brew I attempted using sudo port install watchman with MacPorts, removing the .watchmanconfig file and re-creating it, and lastly restarting my device, but none of these solutions have seemed to work for me.
Whenever, I open my react native project and run the command npm start, this is the output that I see,
jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
Usually this happens when watchman isn't running. Create an empty `.watchmanconfig` file in your project's root folder or initialize a git or hg repository in your project.
...
watchmanResponse: {
error: 'std::__1::system_error: open: /Users/USER/Desktop/ReactNativeApp: Operation not permitted',
version: '0.0.0'
}
This error message ends the npm start and because of this, I am unable to run npm run ios and continue with the development of the application. If anyone happens to know of any fixes or has experienced this before I would appreciate it if you share how I can resolve it. Thank you.
We can resolved this when we put our project outside from those folder Desktop,Download and Document
then run
npm start
It will be work
thanks

yarn no longer present

Been running my npm start, which uses yarn, over and over for the last 5 months and has been working since day dot. I even see it in my Terminal history 10 lines above.
> yarn
yarn install v1.10.1
I killed my npm start process a moment ago, and now for some reason, I get this...
> yarn
sh: yarn: command not found
Yarn is no longer installed on my system...for some reason. So I installed it and get the usual information that it's installed.
$ npm -g install yarn
+ yarn#1.12.3
added 1 package in 2.786s
But yarn still isn't installed and I'm still getting the same above issue.
I haven't done anything that would have messed up yarn in anyway (no installing/updating/removing of any packages), so I'm completely stumped as to what the heck happened.
Has anyone had this issue, know what it is and has a fix?
After a bit of playing around, it seems that killing yarn in the process of it doing it's update, killed it's global link (e.g. /usr/bin/yarn) to it's binary.
So I ran the yarn application from it's full path, which I got from the npm install -g yarn (in my case /usr/local/Cellar/node/10.12.0/bin/yarn).
This then updated yarn, reinstalling the links and fixing it, and now it's all working. :)

Can't run "npm install expo-cli --global"

I am a newbie in all this stuff. Hope for your understanding.
Let me clarify the issue:
I am trying to start react native app through expo cli. So tried to start npm install expo-cli --global to install npm globally. I got these errors:
Screen_1
Screen_2
It also says that I lack permissions to access it. How can I allow permissions?
Even when I try to start it locally I got the same issue. Your help is appreciated.
although this solution is not the best and the safest solution exists, this worked for me and that make sense because all the problem we had with the errors is the permission problems. so you can use this command and ignore those permission problems :
sudo npm install expo-cli -g --unsafe-perm
I was having the same problem with npm install -g expo-cli, having "MODULE_NOT_FOUND",
I installed yarm with brew, just in case you do not already have it:
brew install yarn
and then use:
yarn global add expo-cli
to create a project you can:
expo init nameOfTheNewProject
and choose a template in the console.
Finally run the project with
yarn start
Let me know if it works for you!
You did not mention which os. This answer working for any operating system (ubuntu in my case)
I'm also getting permission errors when running
sudo npm install --global expo-cli
Which I don't really how this can happen - as this also happens for the superuser!
For me it works when I install the client locally into the project
cd <new-project-dir>
npm init # init npm project
npm install expo-cli
Now you can use the client in this project like this:
npx expo-cli # e.g. npx expo-cli init <project-name>
npm cache clean --force
This will solve the issue
Try using npm install -g expo-cli#3.5.0 this worked for me, it may work for you.
You can try this command:
npm install -g expo-cli
or,
yarn global add expo-cli
You have to run the command as administrator from a command prompt on windows and not bash. Had me stumpt for bloody ages!
You need administrator privilege. So when you open command line interface, just right click and run as administrator
This will solve the problem
I guess, this issue comes from permission or node version , if you get this error when the node module is being refreshed ---> This is definitely a permission issue. Disable your Antiviruses or change permission manually check this as well.
First run npm cache verify, then run sudo npm install --global expo-cli.
Did work for me indeed after trying so much.
Follow the steps
First, run npm cache verify.
Open Windows PowerShell as administrator and run npm install expo-cli
--global --no-optional command.
npm cache clean --force then npm install --unsafe-perm -g expo-cli
It is likely you do not have the permissions to access this file as the current user.
The best way to solve this problem is to reinstall npm with a node version manager.And you don't need to remove your current version.
About node version manager
use nvm or n with OSX or Linux
use nodist or nvm-windows with windows
Upgrade Node version to +10
Then do
sudo npm install expo-cli -g
This worked for me. I hope this would solve your problem!
sudo npm install expo-cli -g --unsafe-perm=true --allow-root
If any of the solutions above result in success, please follow the steps below:
Uninstall Node.js
Restart your pc/mac
Download latest version of the Node.js (https://nodejs.org/en/)
Open cmd as admin mode or use "sudo" before the command line on Mac.
npm install expo-cli --global
I hope it can help
In my case, I deleted two files then everything worked. The two files are in this path: C:\Users\{Username}\AppData\Roaming\npm under the names 'expo.ps1' and 'expo-cli.ps1'
Then run:
npm i -g expo-cli
re-install node.js, it works for me
First update Node.js to the latest stable version and then again try to install expo ad clean before expo folders that are being created in below location
C:\Users\{{computer_username}}\AppData\Roaming\npm
If it's throwing error in visual studio code, try from cmd, was facing same error but solved through this way
npm install -g expo-cli
try going into windows resource monitor and terminating adb.exe (android resource bridge). This worked for me after searching for solutions for days. I tried this after verifying cache, clearing cache, you name it.
As a Debian 10 buster user I got the same permission error while using this command: sudo npm install expo-cli --global.
The problem was solved by installing expo-cli with yarn package manager and the command below: sudo yarn global add expo-cli.
For Windows User :-
Open your Powershell and type:
npm install expo-cli --global
This worked for me after trying and reasearching for hours.
Note:Don't Use cmd or any other terminal and also don't type npm install expo-cli -g as it is written in the react native docs. It would always show up an npm error.
For windows
Follow these steps carefully
open the command prompt and run it as administrator.
recommended npm uninstall --global expo-cli.
run the command npm cache clean --force.
run the command npm cache verify .
now run the command npm install --global expo-cli
dont run command like npm i -g expo-cli or npm install -g expo-cli.
7.Make sure you run the command mentioned in the 4th step ONLY.
thankyou.
I had this problem in Windows 10, to be able to install the latest version (I had no choice since it broke the current one). I had to install the latest version of Python (3.8.0) and then run npm install --global --production windows-build-tools as an administrator, then I was able to run again: npm install expo-cli --global to install the version 3.8.0 of the expo-cli
Here is the solution and 100% working. I am working with Windows and not sure abut Linux.
Open cmd and
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
then press yes
Now run the command to start your project
npm install -g expo-cli
I had previously removed Expo from my Windows machine and encountered this error whilst trying to reinstall. Reading the error message solved the problem.
npm i expo-cli -g --legacy-peer-deps
Using this command in 'PowerShell' installed expo successfully.
If anyone else has this problem here is my fix, go to Finder, in the input field (search box) type in /usr/local/lib then press CMD + SHIFT + G press the OK button or whatever pops up, then CMD + SHIFT + . and delete the NVM file i deleted the expo folder too. Then go to this link https://changelog.com/posts/install-node-js-with-homebrew-on-os-x
follow the instructions and install brew, node, etc. Last step go to your terminal and type sudo npm install expo-cli --global
First: I upgraded my mac version 10.13 to 10.15
Then I downloaded homebrew, Watchman, Git and Node.js
Finally I ran this command sudo npm install --global expo-cli --legacy-peer-deps
If you have any further questions check the docs out: https://docs.expo.dev/get-started/installation/
Sometime, I use npm not work.
I try a lots times run with npm but fail for expo cli.
Please try yarn global add expo-cli
It wills save your time ^^.
I was trying to install expo-cli with my company npm registry configured.
I've created 2 differents profiles using npmrc and using the profile with https://registry.npmjs.org/ solved the issue.

No bundle URL present (react native)

Just installed react native and trying to get Hello World up and running. Been receiving this error for the last few hours:
"No bundle URL present.Make sure you're running a packager server
or have included a .jsbundle file in your application bundle."
I've referred to this: What means of no bundle URL present in react-native? and other similar questions, and tried everything: using my ip addresse, different combos of react-native run-iso and npm install while running and not running, tried deleting builds, cleaning project, restarting Xcode, simulator multiple times, tried react-native-upgrade, edited into.plist to allow arbitrary loads, manually setting the path to my index.ios.js, everything, and nothing works.
I noticed many ran into this issue when trying to build on their device. i'm not trying to do anything fancy, just get 'hello world' up and running.
Any other solutions I am not aware of?
cd into YOUR_PROJECT/ios and rm -r build, then run again react-native run-ios
I have the same issue, my problem was with info.plist I just
config it as the following:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
from this solution https://stackoverflow.com/a/48471978/1627358
And then add Bash config file .bashrc with this command:
echo "alias rni=\"kill \$(lsof -t -i:8081); rm -rf ios/build/; react-native run-ios\"" >> ~/.bashrc; source ~/.bashrc
Then run rni
from this solution https://stackoverflow.com/a/44080527/1627358
And it works fine with me.
run the following code:
killall -9 node
rm -rf ios/build
react-native run-ios
it will open launchpackager.command and the application will install on the ios simulator
The solution that worked for me.
You need to run:
yarn start
And at the same time (in a different terminal window):
yarn run:ios
Assuming that you are using nvm and multiple versions of node installed, here is the solution:
Say that you run npm install -g react-native-cli in node v6.9.5.
Now make node v6.9.5 as default by running nvm alias default 6.9.5
Now run react-native run-ios
The problem is, you have multiple versions of node installed via nvm and to install react-native-cli you have switched or installed latest version of node, which is not marked as default node to point in nvm yet. When you run react-native run-ios this opens up another new terminal window in which default nvm is not pointed to the node version where you have installed react-native-cli. Just follow the above setup, I hope that should help.
Answered the same here: https://stackoverflow.com/a/45267703/1292050
I had this issue after I run the following commands to clean the project to see the changes which were invisible because of the cache and so on:
watchman watch-del-all
rm -rf node_modules && npm install
rm -rf /tmp/metro-bundler-cache-* or npm start -- -- reset-cache
rm -rf /tmp/haste-map-react-native-packager-*
The reason for the issue was in the comment in dom-structure which didn't let the application run on the device. So, check the comments too ;)
faced similar issue while running in real device app was getting crash after uploading to testflight upload and install folks this issue is killer
saved by this link
https://onexlab-io.medium.com/no-bundle-url-present-fixed-ca2688a80f66
The solution that worked for me.
> sudo vim /etc/hosts
add
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
then
> sudo killall -HUP mDNSResponder
the reason is I change hosts
I had the same issue happen to me not too long ago. It appears that if you renamed the project to something else and the project folder itself was renamed, you need to make sure you replace all instances of the old name with the new name and do not forget to change file names of your .xcscheme in ProjectName > ios > ProjectName.xcodeproj > xcshareddata > xcschemes. I also had to remove the build directory. Hope this works for you as well!
I've run into this issue when I tried to sync my files to iCloud Drive. I have no idea what causes this, but as soon as I turn off my iCloud Drive and reinstall brew and Node, it started to work again. I can only think that when I turned on iCloud Drive, I might have ended up having two different Node versions or any other dependency.
To debug, your best first step is to scroll through the log text that outputs in the terminal window where you fired off "npx react-native run-ios" and search for the word like "error" or "failed". This will point you toward something more specific than the general "No bundle URL present" error.
For example, you might see something like "BUILD FAILED The following build commands failed: ProcessInfoPlistFile". In this example, I'd then know to go check on my Info.plist. You might see something different, but the debug methodology would still be the same.
If you are trying to run iOS, another idea is to build your app with Xcode itself by opening <YOUR_PROJECT_NAME>.xcworkspace with Xcode, then review its error messages.
Similarly, if you are trying to run Android, then try running with Android Studio and review its error messages.
Lots of answers are given, but one thing you should surely be taking care of while facing this issue is to
make sure that your Metro server is running.
npx react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'
Try This, clear project, and run in xCode.
This relates to the answers from #Daria Kozlova and #Daniel Twork
I needed to have the server running in another tab, i.e. yarn start
But what I hadn't noticed is that the server had crashed with an error like:
jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
Usually this happens when watchman isn't running. Create an empty `.watchmanconfig` file in your project's root folder or initialize a git or hg repository in your project.
Error: Watchman error: std::__1::system_error: open: /Users/anentropic/Documents/Dev/Work/myproject/mobile-app: Operation not permitted. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.
...
watchmanResponse: {
error: 'std::__1::system_error: open: /Users/anentropic/Documents/Dev/Work/myproject/mobile-app: Operation not permitted',
version: '2022.09.12.00'
}
The fix for that can be found here:
https://github.com/facebook/watchman/issues/977#issuecomment-1189903929
i.e. run:
watchman watch-del-all
watchman shutdown-server
and then yarn start again
react-native run-ios works now
just try,
npm start
npm react-native run-ios
The below solved the same problem i had
brew update
brew reinstall watchman
Edit /etc/hosts
127.0.0.1 localhost
this is work for me !!!

'react-native' is not recognized as an internal or external command, operable program or batch file

I recently started with react-native. I install it using the tutorial on the Facebook site and everything works well for a day or two until this message comes up:
'react-native' is not recognized as an internal or external command,
operable program or batch file.
Nothing works except uninstalling everything and starting all over again. The environments are ok and work (npm, choco, etc.). I have also tried removing and adding react-native to environment variables, restarting, and running cmd in administrator mode, but nothing so far. I should add that I use windows 10 64-bit.
I had the same issue and tried the following but didnt work
Adding npm path to my Environment variables; both system and user
Re install npm and react-native-cli
Both didn't work for me, im using Windows 10;
Solution that worked for me is to install react-native-cli globally
You can install it globally by using the below command:
npm install -g react-native-cli
You can simply use npx react-native <command> it will work
npm install -g react-native-cli
But dont forget to restart command promprt
Your system or user environment PATH variable was edited, you can uninstall NodeJs and install it again or add the below path to the end of PATH variable into user variables the restart the Windows :
C:\Users\[USER-NAME]\AppData\Roaming\npm
this should work.
You need to setup the npm path in your environment variables. Please look at the images down below
Then follow the command : for installing -g ( global ) for cli in your system
npm install -g react-native-cli
I get the same error right off the bat on Windows 10 running in cmd window in adminstrator mode, however there is also a bash shell version of react-native that worked for me in a git bash window.
cmd:----------------------------------------------
C:\Users\David\Documents\react>where react-native
C:\Users\David\AppData\Roaming\npm\react-native
C:\Users\David\AppData\Roaming\npm\react-native.cmd
C:\Users\David\Documents\react>react-native init AwesomeProject
'react-native' is not recognized as an internal or external command,
operable program or batch file.
git bash:----------------------------------------
David#CYBER-PC ~/Documents/react
$ react-native init AwesomeProject
This will walk you through creating a new React Native project in c:\Users\David\Documents\react\AwesomeProject
Installing react-native package from npm...
Setting up new React Native app in c:\Users\David\Documents\react\AwesomeProject
AwesomeProject#0.0.1 c:\Users\David\Documents\react\AwesomeProject`-- react#15.3.1
To run your app on iOS:
cd c:\Users\David\Documents\react\AwesomeProject
react-native run-ios
- or -
Open c:\Users\David\Documents\react\AwesomeProject\ios\AwesomeProject.xcodeproj in Xcode
Hit the Run button
To run your app on Android:
Have an Android emulator running (quickest way to get started), or a device connected
cd c:\Users\David\Documents\react\AwesomeProject
react-native run-android
npm install -g react-native-cli
I had to add the %APPDATA%\npm folder to my PATH on Windows 10. Global modules are installed there.
If uninstalling and installing again the npm did not work on you, try adding %APPDATA%\npm to path (Environment variables) then quick reboot/restart. System Reboot should really be part of the process. This worked on my end.
Install :
npm install -g react-native-cli
Uninstall :
npm uninstall -g react-native-cli
If you are following the getting started guide for Windows/Android, they recommend installing nodejs via Chocolatey. But Chocolatey likes to have administrator rights when it installs things. If you're just a regular user, this seems to interfere with how npm installs react-native-cli. In my case, the react-native command was only recognized when I launched a command prompt as admin.
What I did to fix:
launched command prompt as admin
uninstalled react-native-cli globally: npm uninstall -g react-native-cli
uninstalled nodejs via Chocolatey: choco uninstall nodejs
Now, as a regular user without admin rights:
installed nodejs via the nodejs website (not Chocolatey)
installed react-native-cli globally: npm install -g react-native-cli
I uninstalled node.js and then reinstalled it, and it worked like a charm
just uninstall the node.js and reinstall it..
then install the cli package typing command
npm install -g react-native-cli..
now you are ready to make your project.
To make project open a folder from your drive wherever your folder is located.
Then type command
react-native init albums
it will create a project for you inside your directory.
None of the above mentioned solutions worked for me. What did work was to remove nodejs, and reinstall it via Chocolatey with the following command:
PS > choco install -y nodejs.install python2 jdk8
> npm install -g react-native-cli
C:\Users\user\AppData\Roaming\npm\react-native ->
C:\Users\user\AppData\Roaming\npm\node_modules\react-native-cli\index.js
+ react-native-cli#2.0.1
added 41 packages from 15 contributors in 4.528s
I had this problem also becuase I restored my files from a previous OS installation. My problem was a wrong prefix in my C:\Users\user_name\.npmrc file.
Run npm config list and make sure that all your npm config variables are leading to the correct file paths. Delete the .npmrc file if you want have it to go back to the defaults. That's what I did and react-native command is working for me again.
I hope this helps.
i have no clear idea but below steps worked for me.
delete Node Modules
Uninstall react-native cli. This is Recommended in the react-native Documentation
"If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues."
npm uninstall -g react-native-cli
clean gradlew. in your project folder, go to the android folder by typing cd android
and run gradlew clean
move back to your project folder cd .., then run
npx react-native run-android
these steps worked for me. took some time when running first time.
use node.js stable version or recommended version.
On window 10, nodejs>11 global node libraries seems to be installed in C:\Users\your_user_name.npm-global. So you need to set the variable to point to that path
I had problems because of this strange mistake.
I checked to see if it was globally loaded again
I didn't delete all packages
I even deleted C:\Users[USER-NAME]\AppData\Roaming\ npm manually, but there was no solution.
The only thing that is the solution is to use the current version of node.js.
uninstall nodejs completely(restart your pc) and reinstall it using chocolatey and follow other commands from https://facebook.github.io/react-native/docs/getting-started.
worked perfectly fine for me!
Even if you have installed react-native globally and still get the same try adding path of npm module (C:\Users\your user name\AppData\Roaming\npm) to system variables instead of user variables.
I know it's too late, anyway
Make sure you've added the path of the NPM in system variable rather than user variable in the System Environment Variables.
PATH : C:\Users\user_name\AppData\Roaming\npm
Open a the command prompt and type: npm config list:
Get the path underlined in red and add it your system path (change two back slashes into one), for example: C:\Users\YOURNAME\AppData\Roaming\npm.
This solved the issue for me
I just wrote "react-native -v" to console to check have I still react-native and then just I wrote "react-native run-android" again and this time it worked. Yes just that. React native is terrible technology.
Looks like I have uninstalled react native cli by mistake, I tried all answers mentioned above, but the below command worked for me.
npx react-native run-android.
Solution
I was facing 'react-native' is not recognized as an internal or external command,operable program or batch file error when I was running react-native start in VsCode.
I Solved it by running npm install -g react-native-cli in PowerShell
Steps to follow
run PowerShell as admin (important step)
run running npm install -g react-native-cli in PowerShell
close VsCode and rerun it
that's all!
I solve this problem by running
npm install -g react-native-cli
then another error appears
Command run-android unrecognized.
I fixed this error by
npm install
Use npx before your command
npx react-native
Not just
react-native
if you faced the same issue as me just type :
npm i react-native
then try to create a new project as its recommended by the react native doc by typing :
npx react-native init yourProjectName
this should resolve your problem
hope this was helpful