Crawl computer for node_modules, add .nosync file
You can run the following to create a .nosync file in each node_modules folder
find ~ -type d -name node_modules -exec touch {}/.nosync \;

This will look through everything in your home directory. You can limit it to the Desktop folder by replacing ~ with ~/Desktop.
To have the command run regularly you can create a crontab entry:

Run EDITOR=nano crontab -e to start editing. If you haven't created another entry before the file will be empty
Add
0 * * * * find $HOME -type d -name node_modules -exec touch {}/.nosync \; 

to have it run every full hour, or
0 */3 * * * find $HOME -type d -name node_modules -exec touch {}/.nosync \; 

to run it every three hours
Type Ctrl-X and answer &quot;Y&quot; on the save prompt