npm start error — System limit for number of file watchers reached
Issue 1:
While starting a react js project using “npm start” on RHEL platform, you might come across the error — system limit for number of file watchers reached.
Issue 2:
Sometimes, while starting a jhipster reactjs project in dev mode using “npm start” on RHEL platform, the project starts successfully but the browser fails to auto reload the changes made to the app dynamically.
Solution:
Both of above issues can be resolved by increasing the system limit for number of file watchers.
$echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
You might also prefer to increase the max-old-space-size for node js project using below command.
NODE_OPTIONS=--max-old-space-size=1536
“Old space” is the biggest and most configurable section of V8’s managed (aka garbage-collected) heap (i.e. where the JavaScript objects live), and the --max-old-space-size
flag controls its maximum size. As memory consumption approaches the limit, V8 will spend more time on garbage collection in an effort to free unused memory.
References: