how to ignore all the node_modules folders from time machine

How to add the node_modules folder paths to time machine ignore paths. These folders are like tmp data for backups. These are very dense folders and also slow down TM. Is there is a txt file which can be appended? Maybe a command line which can append to the config.


I'm one of the maintainers of Asimov, a free macOS utility for automatically excluding development dependencies (npm, Composer, RubyGems, and more). It was designed for this very purpose ::looks begrudgingly at node_modules/::

The easiest way to install Asimov is via Homebrew (brew install asimov), but the GitHub repo also has manual installation instructions. Once installed, a cron job runs every day to find development dependencies and automatically exclude them from Time Machine via tmutil (mentioned above).

One more benefit is that Asimov checks for the dependency declarations (in the case of node_modules/, a package.json file) before excluding the directory from backups.

Hope it helps!


You can manage the list of ignored folders in the Time Machine preferences.

enter image description here


There're several approaches mentioned in this gist.

  1. Using tmutil addexclusion
find `pwd` -type d -maxdepth 3 -name 'node_modules' | xargs -n 1 tmutil addexclusion
  1. Using tmignore which automatically finds all Git repositories on your disk and excludes all paths matching .gitignore files. I've just tried it and it works great. You can also set up a script to check your disk periodically.