【问题标题】:React Native `npm start` with watchman error用守望者错误反应本机`npm start`
【发布时间】:2017-03-17 18:50:54
【问题描述】:

我第一次遇到这个问题:https://github.com/facebook/react-native/issues/10088

然后我按照这个解决方案解决了这个问题:https://github.com/facebook/react-native/issues/910#issuecomment-94181845

现在当我输入npm start 时,我得到[sane] Warning: Lost connection to watchman, reconnecting..。有什么建议吗?

更新:当我将我的 MacOS 更新到 MacOS Sierra 时,这开始发生。

更新:所以我尝试运行react-native run-ios,它会打开一个新的控制台窗口并调用npm start。它仍然会发出[sane] Warning: Lost connection to watchman, reconnecting.. 警告,但它会构建捆绑包。所以守望者之间的联系被打破了。这是控制台屏幕截图:

【问题讨论】:

标签: facebook reactjs react-native native watchman


【解决方案1】:

我按照 David 提供的解决方案解决了这个问题,但我必须做一些额外的步骤,因为我已经使用 brew 安装了 watchman。以下是解决方案的命令列表:

删除守望者(由 brew 安装):

$ brew install rmtree
$ brew rmtree watchman
$ sudo rm -rf /usr/local/var/run/watchman

手动安装 Watchman v4.7.0(感谢 David):

$ git clone https://github.com/facebook/watchman.git
$ cd watchman
$ git checkout v4.7.0
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

chmod 用户的守望者状态目录:

$ chmod 0700 /usr/local/var/run/watchman/<user>-state

【讨论】:

  • 我在打包 Exponent 应用程序时遇到了同样的问题。看起来这是旧版本守望者的一个已知问题(facebook.github.io/watchman/docs/troubleshooting.html,一直滚动到底部)。一个简单的“brew reinstall watchman”为我做了。
  • brew install rmtree 对我不起作用,但 brew tap beeftornado/rmtree 代替了工作
  • make 对我不起作用。我收到一个错误:root/stat.c:188:13: error: logical not is only applied to the left hand side of this bitwise operator [-Werror,-Wlogical-not-parentheses].
【解决方案2】:

在项目文件夹中运行此命令

watchman watch-del-all && npm start --reset-cache

【讨论】:

  • 不走运 :( 仍然收到相同的警告:Lost Connection to watchman, reconnecting...
【解决方案3】:

我有一个类似的问题,查看 Watchman 的日志时,每次看到“与 Watchman 的连接丢失”消息时都会出现这些错误。

2016-11-05T03:35:48,401: [listener] Watchman 4.7.0 <no build info set> starting up on Davids-Mac.local

2016-11-05T03:35:48,401: [listener] path /Users/david/Projects/react-native-test is on filesystem type hfs

2016-11-05T03:35:48,402: [listener] root /Users/david/Projects/react-native-test using watcher mechanism fsevents (auto was requested)

2016-11-05T03:35:48,406: [listener] file limit is 2560 kern.maxfilesperproc=10240

2016-11-05T03:35:48,406: [listener] raised file limit to 10240

2016-11-05T03:35:48,407: [listener] Using socket from launchd as listening socket

2016-11-05T03:35:48,934: [io 0x7f8175600ff8 /Users/david/Projects/react-native-test] PERF: {"ru_nvcsw": 0, "ru_nsignals": 0, "ru_msgrcv": 6, "ru_msgsnd": 6, "ru_inblock": 0, "ru_majflt": 0, "ru_nswap": 0, "ru_minflt": 5230, "ru_ixrss": 0, "ru_maxrss": 21405696, "system_time": 0.32367200000000002, "user_time": 0.18271599999999999, "elapsed_time": 0.53129999999999999, "pid": 9867, "ru_idrss": 0, "meta": {"root": {"watcher": "fsevents", "ticks": 2, "number": 1, "case_sensitive": false, "recrawl_count": 0, "path": "/Users/david/Projects/react-native-test"}}, "version": "4.7.0", "ru_oublock": 0, "ru_nivcsw": 112, "start_time": 1478316948.403332, "description": "full-crawl"}

2016-11-05T03:35:48,935: [io 0x7f8175600ff8 /Users/david/Projects/react-native-test] crawl complete

2016-11-05T03:35:49,029: [client=0x7f8176a00038:stm=0x7f8176a00000] Unilateral payload for sub sane-sub {"settled": true}

Terminating due to signal 11 Segmentation fault generated by pid=0 uid=0. address not mapped to object (0x0)
0   watchman                            0x0000000105973759 _ZL13crash_handleriP9__siginfoPv + 347
1   libsystem_platform.dylib            0x00007fffa2292bba _sigtramp + 26
2   ???                                 0x00007f81756000c0 0x0 + 140193996734656
3   watchman                            0x000000010596f9b2 _ZN6detail22estimateSpaceToReserveIPKcJA3_cA28_c8w_stringA2_cPcS6_EEEmmRKT_DpRKT0_ + 109
4   watchman                            0x000000010596f815 _ZN8w_string5buildIJPcRA4_KcPS2_RA3_S2_RA28_S2_RS_RA2_S2_RS1_SC_EEES_DpOT_ + 121
5   watchman                            0x000000010599b4cb _ZN8watchman3Log3logIJRA28_KcR8w_stringRA2_S2_RPcS8_EEEvNS_8LogLevelEDpOT_ + 183
6   watchman                            0x000000010599a6e0 _ZNSt3__114__thread_proxyINS_5tupleIJZL15make_new_clientP15watchman_streamE3$_0EEEEEPvS6_ + 952
7   libsystem_pthread.dylib             0x00007fffa229cabb _pthread_body + 180
8   libsystem_pthread.dylib             0x00007fffa229ca07 _pthread_body + 0
9   libsystem_pthread.dylib             0x00007fffa229c231 thread_start + 13

更新: 好的,找到了一个到目前为止似乎可行的解决方案。我完全卸载了 watchman,然后使用以下代码从源代码构建它,这似乎工作正常(任何通过 brew 安装的尝试都会导致上述问题,但这有效):

$ git clone https://github.com/facebook/watchman.git
$ cd watchman
$ git checkout v4.7.0  # the latest stable release
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

【讨论】:

  • 只是想补充一点,我可以通过执行以下操作来解决此问题:
  • 好吧,我让它工作了,但是在运行 sudo make install 之前我必须做 sudo rm -rf /usr/local/var/run/watchman。在sudo make install 之后我不得不做chmod 0700 /usr/local/var/run/watchman/&lt;user&gt;-state
猜你喜欢
  • 1970-01-01
  • 2020-01-26
  • 1970-01-01
  • 2019-11-19
  • 2020-04-03
  • 1970-01-01
  • 1970-01-01
  • 2018-12-28
  • 1970-01-01
相关资源
最近更新 更多