node.js 报错Error: ENFILE: file table overflow...ENFILE: file table overflow, open...

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

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

产生这个问题主要是苹果操作系统的限制,具体参考这个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
发布了94 篇原创文章 · 获赞 42 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/qq_29483485/article/details/88692950