node_modules
In this blog post, I describe how you can ignore node_modules
by bidirectionally syncing into a cloud directory (as managed via Dropbox etc.).
node_modules
make sync services difficult to use Challenge:
node_modules
, due to the sheer amount of small files.Possible solutions:
node_modules
. This will be a good mid-term solution.node_modules
. Alas, the basic versions of Dropbox, iCloud, and Google Drive don’t let you do that at the moment.node_modules
while doing so.We’ll look into (3) next.
Unison is a tool for bidirectional file synchronization that runs on macOS, Unix, and Windows. Its website describes how to install it. Caveat on macOS: If you want the watch mode to work, a tool called unison-fsmonitor
must be available via the shell. I’m using autozimu’s unison-fsmonitor and it works well for me.
The following shell script watches and syncs continuously:
unison -repeat watch -copyonconflict -prefer newer \
-ignore 'Name {node_modules,.DS_Store}' \
'/Users/rauschma/Projects/' \
'/Users/rauschma/Library/Mobile Documents/com~apple~CloudDocs/Projects'
Options:
-repeat watch
: Unison watches both sync directories for changes and syncs incrementally when it detects any.-copyonconflict -prefer newer
: Resolve conflicts automatically.-ignore
: Ignore the specified files during syncing.