Member-only story

Ignoring node_modules folders in Dropbox

Justin Ohms
2 min readOct 22, 2021

Now that Dropbox has finally added the ability to ignore folders inside the Dropbox folder it’s time to update the way I ignore node_modules folders.

Photo by Gabriel Heinzer on Unsplash

I used to simply keep my node_modules directories symlinked to an alternate location, however, recent changes in the way npm works have caused this to stop working as npm no longer allow this folder to be a symlink and will delete and recreate it as a folder.

The command to ignore a file or folder in Dropbox is pretty straightforward and can be found on the Dropbox help site.

Of course, being a programmer I wanted a way to automate this process. My goal was to ignore all top-level node_modules folders (which would also, therefore, ignore any node_modules folders in subdirectories)

Note that this command is for MacOS but some variation of the command below should work for Windows or Linux

find ~/Dropbox  -type d | grep 'node_modules$' | grep -v '/node_modules/' | xargs -I {} -t -L 1 xattr -w com.dropbox.ignored 1 "{}"

Command breakdown:

  • find all directories in ~/Dropbox
  • use grep to filter to only the directories that end in node_modules
  • use grep to exclude from that directory list those that also include node_modules/ **

--

--

Responses (1)