[React Native] Suddenly I couldn’t build my React Native App. (Cause and Solution))

React

Background

Suddenly I couldn't build my app and console showed an error with red message, which said

Error: EMFILE: too many open files, watch

Emitted 'error' event on NodeWatcher isntance at:
     at NodeWatcher: checkedEmitError (.../react-native-project/node_modules/sane/src/node_watcher.js:143:12)
     at FSWatcher.emit (events.js:210:5)
     at FSEvent.FSWatcher:_handle onchange (internal/fs/watchers.js:129:12) {
   errno: -24,
   syscall: 'watch',
   code : 'EMFILE',
   filename: null
)
Process terminated. Press <enter> to close the window

You can refer the detail below.
https://stackoverflow.com/questions/58675179/error-emfile-too-many-open-files-react-native-cli

watchman

As you can see the aticle where I refered just the above it can be solved by using watchman.

This library basically watches files in a certain folder recursively but also solves the problem I mention in this article.

You can see all of commands in the below.
https://facebook.github.io/watchman/docs/cmd/watch-del-all

I try watchman

watchman watch-project `path`

But even if I wait some minutes it doesn't response at all.

But I tried to watch another folder.

watchman watch-project `another_path`

Watchman answerd

    "version": "2024.08.26.00",
    "roots": [
        "/Users/kkitaya/ReactNativeProject/hlsplayer"
    ]

Definetly it can be monitored....

Cause of the problem

You must create .git in your foloder where you want to watch by watchman.

git init `path`
watchman watch-project `path`

After that I could watch my foloder and build my app.

コメント

タイトルとURLをコピーしました