'Node.JS [nodemon] Internal watch failed: ENFILE: file table overflow

[nodemon] 1.19.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: src/**/*
[nodemon] starting `ts-node index.ts`
[nodemon] Internal watch failed: ENFILE: file table overflow

I tried killing node process, and also tried running

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p I get

sysctl: illegal option -- p
usage: sysctl [-bdehiNnoqx] name[=value] ...
       sysctl [-bdehNnoqx] -a

But these doesn't seem to work. I'm using macOS 10.15.3



Solution 1:[1]

I was having the same problem.

sudo launchctl limit maxfiles 65536 200000

worked for me. Found it here: https://wilsonmar.github.io/maximum-limits/

Solution 2:[2]

You need to limit the number of files and processes that are allowed to be open. This limit protects the system from being overrun.

Run

sudo launchctl limit maxfiles 65536 200000

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jon
Solution 2 yansusanto