79625297

Date: 2025-05-16 13:40:05
Score: 2
Natty:
Report link

Everybody seems to be pointing at increasing the max watches, always to this magic number:

fs.inotify.max_user_watches=524288

What happens when you're already at that setting and still have the same error?

TL;DR

I think the simplest solution, before even starting meddling with obscure settings would be to simply run:

sudo sysctl -p

This alone will refresh the system and forget previous watched files. For me, it works every simgle time.

More details

As it seems, whenever you run something like npm run start|dev (depending on whether you're using Webpack or Vite), everything inside node_modules is put under watch. Have you seen node_modules? I have in a single project over 1000 folders inside it, and 96 different file types, clocking almost 35000 files!

There are rumours of an NPM package with pictures of the author's dog, or girlfriend, or both, or of a dog that is also the author's girlfriend... I forget now.

In a much more controlled fashion, Python virtual environments also have multiple files and a Django runserver will also watch everything under its purview.

Bottom line is, Linux loads all those file names into some sort of in-memory structure and they just stay there, even after you interrupt your npm run .... If you're one of those devs that reboots their laptop every day, you might never hit this. But if, like me, you hibernate because you have 10 workspaces and tons of stuff open (fullstack working on multiple projects), then this will happen, not if, but when.

So,if you're not running a ton of projects at the same time, try the little sudo sysctl -p and just be happy.

If you happen to be rich enough that your laptop can actually run all that in one go, then I'd recommend either segregate your projects into VMs, or just containerise them, because containers are like Vegas: "what goes in docker stays in docker."

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): have the same error
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Ricardo