升级OS10.12之后,react-native的本地服务突然不能正常启动了。怀疑是react-native版本问题。从0.28.x的版本切换到0.33.x的版本,还是不能启动,报错如下:
FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
ERROR watch null EMFILE
{"code":"EMFILE","errno":"EMFILE","syscall":"watch null","filename":null}
Error: watch null EMFILE
at exports._errnoException (util.js:890:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1296:21)
修复方法:升级watchman版本至4.6
We were able to get it to work by increasing the max file limit and moving to watchman v4.6.0
here are the steps we followed:
- increase max file limt
check open file limit
sysctl kern.maxfiles
edit sysctl
sudo vim /etc/sysctl.conf
add these two lines
kern.maxfiles=10485760
kern.maxfilesperproc=1048576
reboot
sudo reboot
check new file limit
sysctl kern.maxfiles
- upgrade to watchman 4.6
clone repo
git clone https://github.com/facebook/watchman.git
change to master branch
git checkout -b v4.6.0 v4.6.0
run compiler
./autogen.sh
./configure --enable-lenient --without-pcre --with-python
make
sudo make install
check watchman version
watchman -v
result should be 4.6.0
其中1步骤失败了。2的步骤成功。
可以启动本地服务器了。