Take Your Search Game to the Next Level with Dropbox Dash  🚀✨ Curious how it works? Ask us here! 

Forum Discussion

sebastian_'s avatar
sebastian_
Collaborator | Level 8
6 years ago
Solved

How to make Dropbox ignore node_modules folder with symbolic links (aliases)

PROBLEM
 
Dropbox does not currently provide an ignore file/folder feature that enables a locally-unique instance to exist on each machine. One important use of this is the “node_moduels" folder used for node javascript development. The node_modules folder sees thousands of file changes during the development cycle. If this folder is allowed to sync, the important files you need (outside of it), are so far down in the sync queue that you never have the important files when you need them on your other systems.
 
SOLUTION
 
A better way to sync projects with Dropbox while ignoring the node_modules folder is to use a “properly” formed symlink (alias). At this time npm and yarn support a property formed symlink. HOWEVER, IT IS CRITICAL THAT THE LINK (ALIAS) AND TARGET HAVE THE SAME NAME!
 
From shell prompt (terminal):
 
  1. cd YOUR_PROJECT_NAME
  2. mkdir -p ~/Downloads/node_modules_for_YOUR_PROJECT_NAME
  3. mv node_modules ~/Downloads/node_modules_for_YOUR_PROJECT_NAME
  4. ln -s ~/Downloads/node_modules_for_YOUR_PROJECT_NAME/node_modules

 

Now create the same target node_moduels folder on each of your other systems **AFTER** Dropbox syncs the ENTIRE project direcotry. The old node_modules folder should be removed and the symlink (alias) added before running these steps.

 
  1. cd YOUR_PROJECT_NAME
  2. mkdir -p ~/Downloads/node_modules_for_YOUR_PROJECT_NAME/node_modules
  3. yarn install
 
 
SUCCESS
 
Dropbox WILL sync the symlink/alias file itself, but NOT the contents it points to. This seems to work well for file syncing across several of your own development systems, and then use git to push to the repo for others on the team.
 
CAVEAT
 
The tiny symlink (alias) file itself IS sync’d on all systems, but will point to a non-existent / empty folder on the other systems. This is most applicable for a single user, but can also be useful for teams if an individual variant of the ignored data is appropriate, such as for node_moduels.
 
Hope this helps.
 

🙂

..sebastian

  • sebastian_'s avatar
    sebastian_
    6 years ago

    NOTE: The Initial Post on this thread IS the Solution. While the technique specifically targets the node_modules folder in Javascript / TypeScript projects, it can also be applied to any "folders" that need to be ignored (see bottom of this post for a drag-n-drop technique).

     

    HOW IT WORKS

    Because Dropbox does not synchronize folders referened by symlinks (aliases), you can move those folders into a NON-DROPBOX path (outside of dropbox), then create a symlink (alias) in the original Dropbox location.

    RESULT

    The ignored folder in Dropbox looks and behaves as normal folder, but in reality the data lives in a non-synchronized location on the storage device.

    HOW TO IGNORE ANY FOLDER (THE DRAG-N-DROP WAY)

    1. Move the folder to ignore "Outside of Dropbox" into another location (e.g. ~/Documents)
    2. In Finder (Mac OS), Command+Option Drag the folder back into Dropbox to create an alias. The cursor should turn into a little curved arrow while dragging if you have the right keys pressed. Once dropped, an alias will be created in the original Dropbox location pointing to the moved folder.

    NOTE: Using symlinks/aliases on Windows and Linux should behave the same way, but I have not verified it. Also, I've updated the original post to state that the tiny symlink (alias) file itself "IS" copied to all systems, but not the content of the folder.

    ..sebastian

19 Replies

About View, download, and export

Need support with viewing, downloading, and exporting files and folders from your Dropbox account? Find help from the Dropbox Community.

Need more support

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!