Skip to content

Instantly share code, notes, and snippets.

@Hiweus
Last active April 21, 2022 11:47
Show Gist options
  • Save Hiweus/bd6761e0b25ffbd2156b422bc9bb0d9a to your computer and use it in GitHub Desktop.
Save Hiweus/bd6761e0b25ffbd2156b422bc9bb0d9a to your computer and use it in GitHub Desktop.

Watch mode scripts npm

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

See Here

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment