I was working on a project involving technologies, nodejs, reactjs, and sass. And the project was running good till I got the below error:

npm ERR! Error: ENOSPC

Well, I found out that ENOSPC stands for no-space error, which was bit confusing to me (as I have lots of free space).

I also received an error in sass watch as below:

Listen error: unable to monitor directories for changes.
Please head to https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers

I visited the link to find out that nodejs and sass watch uses inotify by default on Linux to monitor directories for changes. And It’s common to encounter a system limit on the number of files you can monitor.

So a simple solution to this is change the max_user_watches in sysctl.
Note: sysctl is used to modify kernel parameters at run-time so use it carefully.

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

This command simple changes the max_user_watches to value 524288 (why this number? I just did as the tutorial said. Its a large number. try other if you want to).