create-react-native-app: Start script hangs without error when there are no available inotify watches
Description
I tried to run npm start in a new project (i.e. I ran the four commands under “Quick Overview”), and it hanged indefinitely (well, at least for several minutes until I aborted) after the output “Starting packager…”.
Running react-native start gave the error ERROR watch {path} ENOSPC, which made me realize that there were no available inotify watches.
After increasing fs.inotify.max_user_watches, npm start started and ran normally.
Expected Behavior
npm start should give a warning or exit with an error saying that there are no available watches, so it can’t start.
Observed Behavior
npm start hanged with this output, and never continued:
$ npm start
> my-app@0.1.0 start /home/trygve/dev/create-react-native-app/my-app
> react-native-scripts start
13.49.26: Starting packager...
Environment
Please run these commands in the project folder and fill in their results:
npm ls react-native-scripts: react-native-scripts@0.0.30npm ls react-native: react-native@0.44.2npm ls expo: expo@17.0.0node -v: v7.10.0npm -v: 4.6.1yarn --version: 0.24.6watchman version: Not installed
Also specify:
- Operating system: Arch Linux
- Phone/emulator/simulator & version: Not relevant
Reproducible Demo
Ran npm start in a clean project just created, so nothing to provide here.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 44
- Comments: 59 (11 by maintainers)
I also have the same issue, using OSX Sierra 10.12.5. sysctl returns
sysctl: unknown oid 'fs.inotify.max_user_watches'. Any ideas? 😦 I can’t start up any react iOS app, the simulator does, but nothing else happens and it gets stuck in the Packager thing…Nevemind, fixed it with this:
@tetralix On Linux do “sudo sysctl -w fs.inotify.max_user_watches=10000”. This changes kernel sysctl value. This is temporary until reboot. To make it permanent, add fs.inotify.max_user_watches=10000 to a file in /etc/sysctl.d directory or /etc/sysctl.conf depending on distro.
@darkguy2008 On my Mac, I had to change the value a little bit, and it worked
Confirming the issue, seen it too and it’s pretty bad bug because it affects newcomers - I’ve created a new empty React native project and it simply hang on “Starting packager…”. Confirming increase of that sysctl fixed the issue.
@nimir : try this in your project root if you haven’t tried yet: ./node_modules/.bin/react-native start
Just ran into this issue. Agreed with the above commenters that something like:
should be added to the error message. Of course adding other relevant information for other OS’s as well. Pretty bad developer experience to have to come to this GH issue & skim to find out what I needed to do just to run the example setup.
FYI, I ran into the same issue again, but fixed with running
I think it would be weird and confusing to come across this error at very beginning. And it would not hurt to mention this in an obvious position of the document, rather than in this issue.
ADMIN EDIT: these commands work for Mac only.
To solve this issue, just install Watchman via Homebrew (for macOS) with:
Source: Watchman docs. For other operating systems, refer to their docs.
I was getting the same error as @mikeaustin
but once i installed watchman, it worked like a charm!
why does sudo sysctl -w kern.maxfilesperproc=524288 solve this problem? Just curious.
Required 10485760 for me
@brentvatne @dikaiosune We should also add this in Getting Started section. So that it will easier for beginners.
I had the same issue on Ubuntu 16.04.2 LTS. As @s417-lama mentioned #51 contains the solution that worked for me.
But this bug is very frustrating for beginners and should be given priority. @dikaiosune has already taken a note of this. I hope this gets fixed soon.
Spent hours googling, reinstalling, upgrading, downgrading, switching to yarn until I found this issue. Thank you!
+1 to have an error message…
Used this guide to increase the inotify watchers max amount: https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers
Maybe just include a URL to watchman – no sense providing install instructions as they vary by platform and could be subject to change, no sense coupling CRNA to the installation instructions for watchman IMO.
e.g.
OSX; ran into same thing, had to read the entire thread to find out what “install watchman” means and that it doesn’t mean npm, agree with comments that it should at least point to the watchman website, although having it suggest “brew install watchman” would be by far the most helpful.
@sendsent
Thanks, actually this is what screwed me up – there is a
watchmanonnpm(https://github.com/dfjones/watchman) which does almost exactly the same thing, and not knowing better I didn’t realize this wasn’t the watchman I was supposed to install (and thus my confusion above). Not sure what a good solution is here given the conflicting package names…I don’t think it should change sysctl config automatically, at least not without asking the user first. And it would require root, which this script shouldn’t have.
Rather I think it should inform the user if there isn’t enough watchers, and print the commands the user should run.
I had the same issue on Ubuntu 16.04. Try to install watchman. If you get some error about watchman when running
npm start, see: https://github.com/react-community/create-react-native-app/issues/51https://github.com/facebook/watchman
As mentioned by @kevz93 I’m thinking of adding a part where it sets the inotify(linux) or kern(macOS) watches and raising a PR. I’m thinking of adding that part here https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/src/util/packager.js#L63. @brentvatne @dikaiosune Please let me know if it’s the place to add.
Note: Adding sudo will ask user to enter the password. I don’t know if it’s okay to do that.
@ide the notice doesn’t say anything about using brew
either install watchman or run the following snippet@vinniejames You should install Watchman from Homebrew per the instructions, not npm.
I ran into the same trouble o a brand new High Sierra install. The notice regarding installing
watchmanis a bit misleading as that package has been deprecated I tried installingfb-watchmanglobally, which didnt help either@anp Please could you link to watchman? I think the “install watchman” error message should include this link.
Did you call your app reactNative by any chance? 😃
@festiveox: 10000 might not be enough. Try to increase it more.
@k3a yes I figured out after some research hehe. Although I appreciate your answer, you can see I fixed my error using those two commands, which are the equivalents for OSX, which I agree with @vs1682 they should be added to the start script 😃