Drummer | Developer | Drum Tech

HomeMusicDevBlog

iCloud and node_modules

tech

May 1, 2020

Update: Unfortunately, there are open issues with webpack and create-react-app that prevent the usage of symlinks, at least easily or without work that I'm unable to do. Sad times.

For now, I've opted to remove all my Node projects out of iCloud, and instead make a habit of creating remote repos on Github.

If you're not using React, the following solution should still work, and I'd still recommend it!

I've been using the COVID-19 lockdown as an opportunity to learn new skills and expand on the ones I've already got. For the most part, this has been in the realm of coding.

I'm not quite ready to share the projects I've been working on (most of them are really basic little web apps that are more for learning than for a portfolio), but I wanted to share one quick little tip for anyone developing adds with Node.js that uses iCloud.

By default, any new file or directory that you store in iCloud on macOS gets uploaded and synced. In the case of a Node.js project, this means that the monster that is node_modules gets uploaded, as well. This is unnecessary usage of bandwidth and also takes quite a toll on your battery and hard disk.

Fortunately, some smart person made a utility for dealing with exactly this scenario: nosync-icloud.

You can read about it on their site, but the short version is that you can run a command in each of your Node.js project folders, and it will look for a node_modules folder, append .nosync to the folder name (which disables iCloud syncing), symlinks node_modules to the newly un-synced folder, and then adds both to your .gitignore.

Brilliant!

Site made by me. Email me or connect on LinkedIn.