Apple System: Error: ENFILE: file table overflow

在MAC上跑nodejs,遇到了一个问题:

Apple System: Error: ENFILE: file table overflow_第1张图片
Paste_Image.png

主要大概是说文件打开太多了,超过了限制。

产生这个问题主要是苹果操作系统的限制,具体参考这个ISSUE

I'm glad this is solving it for everyone. Unfortunately, Apple sets ridiculously low limits by default which might be good for some users, but is awful for developers.
For what it's worth, I would recommend setting the limit much much higher than 65536 (524288 is great).
Additionally, I would recommend using a method that doesn't modify /etc/ files directly since throughout the years Apple has randomly decided to stop loading these files (for example, it used to be a common recommendation to put this in /etc/launchd.conf, but that no longer works in Yosemite).

具体的设置如下:

echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
sudo sysctl -w kern.maxfiles=65536
sudo sysctl -w kern.maxfilesperproc=65536
ulimit -n 65536

你可能感兴趣的:(Apple System: Error: ENFILE: file table overflow)