Ignore node_modules in Dropbox

Node is notorious for generating a rather large number of files in the node_modules when running and npm install. I like to start my projects in Dropbox, which presents a problem with my computer tries to sync tens of thousands of files, sometimes every few minutes if I’m working on a new module for example.

The solution for this problem is to the the “selective sync” feature of Dropbox, however it’s easiest if you haven’t already installed all the module dependencies. First, you want to create your project folder – either a directory followed by npm init, or possibly an existing project from a git or other source code repository.

In this example I will clone my node developer-tools module, which installs binaries and other tools for development work. This module can be found on Github here: https://github.com/doublesharp/node-developer-tools. It will be cloned into the path ~/Dropbox/Workspaces/node-developer-tools. After the directory has been created, we will manually create a node_modules folder inside it.

mkdir -p ~/Dropbox/Workspaces
cd ~/Dropbox/Workspaces
git clone https://github.com/doublesharp/node-developer-tools.git
mkdir -p ./node-developer-tools/node_modules

Now we can exclude this folder from Dropbox sync before filling it up with thousands of tiny files.

1. Select the dropbox icon from you system bar

2. Select the gear icon, followed by Preferences…


3. Choose the Account tab

4. Find the Selective Sync option and click Change Settings…


5. Navigate to Workspaces/node-developer-tools and un-select node_modules

6. Click the Update button


Now you can install the node modules without having the sync to Dropbox.

Unfortunately this needs to be set up for each Node project you want to work with, but the up front investment will save time down the road. Plus a little storage space.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *