Sometimes packages like Nodemon, Mocha who watch changes on files to perform some actions doesnt work correctly 🤕.
All these packages use CHOKIDAR library to watch file changes, to fix this behaviour on chokidar set environment variable CHOKIDAR_USEPOLLING=true.
# Linux
export CHOKIDAR_USEPOLLING=true
# Windows
set CHOKIDAR_USEPOLLING=true
If the project runs inside a virtual machine such as (a Vagrant provisioned) VirtualBox, create an .env file in your project directory if it doesn’t exist, and add CHOKIDAR_USEPOLLING=true to it. This ensures that the next time you run npm start, the watcher uses the polling mode, as necessary inside a VM.