`npm start`问题:ERROR手表EMFILE虽然打开文件限制= 65536

时间:2015-05-25 14:17:16

标签: node.js npm osx-yosemite react-native yosemite

ulimit -a日志:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 709
virtual memory          (kbytes, -v) unlimited

虽然我npm start时仍然出现EMFILE错误。

  

react-native@0.3.11 start / node_modules / react-native   ./packager/packager.sh

 ===============================================================
 |  Running packager on port 8081.       
 |  Keep this packager running while developing on any JS         
 |  projects. Feel free to close this tab and run your own      
 |  packager instance if you prefer.                              
 |                                                              
 |     https://github.com/facebook/react-native                 
 |                                                              
 ===============================================================

在/

中查找JS文件

React packager ready。

 ERROR  watch EMFILE
{"code":"EMFILE","errno":"EMFILE","syscall":"watch"}
Error: watch EMFILE
    at exports._errnoException (util.js:746:11)
    at FSWatcher.start (fs.js:1172:11)
    at Object.fs.watch (fs.js:1198:11)
    at NodeWatcher.watchdir (/node_modules/sane/src/node_watcher.js:144:20)
    at Walker.<anonymous> (/node_modules/react-native/node_modules/sane/src/node_watcher.js:351:12)
    at Walker.emit (events.js:110:17)
    at /node_modules/react-native/node_modules/sane/node_modules/walker/lib/walker.js:69:16
    at FSReqWrap.oncomplete (fs.js:95:15)

2 个答案:

答案 0 :(得分:7)

您忘了安装守望者,以下是您可以这样做的方法:

通过Homebrew在OSX上安装

brew update
brew install watchman

从源代码安装

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

答案 1 :(得分:0)

似乎您正在使用“/”作为节点服务器的根目录,因此根目录下的文件太多会导致错误。