Well well this took me considerable time to resolve this error.
Some Errors are like that you got to dig in for much longer than you would like to. This was one of these for me. I'm sharing my solution here to make it a bit easier for other developers.
When I was trying to run npm/yarn commands which are supposed to watch file changes (e.g. CSS/SCSS or JavaScript files) then it shows Unhandled error problem affects Library React. The related dev- and prod-commands work fine. It's only affecting watch-command and appears to be linked to a file-system incompatibility when watching file changes.
This problem seems to affect especially Linux users like myself. I can't confirm this for sure as I run only Linux- distribution.
events.js:292
throw er; // Unhandled 'error' event
^
Error: ENOSPC: System limit for number of file watchers reached, watch '/home/user_name/chat-app/public'
at FSWatcher.<computed> (internal/fs/watchers.js:218:26)
at Object.watch (fs.js:1525:34)
The one of following methods may help you to get out of this error :
Method $1:
This happens when you have multiple react projects open. Try to close other projects and test again. This happens because your changes on the project are watched on the fly.
Method $2:
Sometimes when this error occurs I used to do npm/yarn install
to update the dependencies and start working. But this may not be handy everytime. Better go with other options.
Method $3:
Visual Studio Code is unable to watch for file changes in this large workspace (error ENOSPC)
This this shows on notification bar of VS Code then refer the beautiful explanation and solution of this issue through VS Code Docs i.e. Solution to issue
Method $4:
Watch a video by Gaurav if you prefer watching video a lot.
Have a good day 😊 !!!
Top comments (4)
Thanks a lot!
You saved me.. I was also using linux(debian) and your post helped me a lot
saved me some time
after closing 2 tabs from another project in VS code it's working :D
multiple tabs with different projects were in VS code.....Thanks a lot... shut down all of them down and restart VS code.