Resolved !  Error- ENOSPC: System limit for number of file watchers reached.
Manvendra Rajpoot

Manvendra Rajpoot @manvendrajpoot

About: Computer Science Enthusiast is interested in Web Development and Machine Learning.

Location:
India
Joined:
Oct 19, 2020

Resolved ! Error- ENOSPC: System limit for number of file watchers reached.

Publish Date: Dec 26 '20
22 5

react

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)


Enter fullscreen mode Exit fullscreen mode

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)


Enter fullscreen mode Exit fullscreen mode

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 😊 !!!

#staysafe😷 #stayhealthy🥗

Comments 5 total

  • Hrithik Tiwari
    Hrithik TiwariJul 31, 2021

    Thanks a lot!
    You saved me.. I was also using linux(debian) and your post helped me a lot

  • Vishal Modanwal
    Vishal ModanwalAug 17, 2021

    multiple tabs with different projects were in VS code.....Thanks a lot... shut down all of them down and restart VS code.

  • Nivethan Ariyaratnam
    Nivethan AriyaratnamOct 28, 2021

    after closing 2 tabs from another project in VS code it's working :D

  • Antony Kimani
    Antony KimaniJul 30, 2022

    saved me some time

  • Mohit
    MohitFeb 19, 2025

    Thanks a lot!.

Add comment