I have a web app located under C:Google-drivevue-app
. Running yarn build
command will install node_modules folder in C:Google-drivevue-app
. I am using Google Drive to sync my web app source code to Google cloud. The problem I am facing is the thousands of files in node_modules will crash Google Drive.
Is there some way to configure package.json to install node_modules folder outside of C:Google-drivevue-app
and have it installed in a location called C:tempnode_storage
?
I am open to any solution that can stop Google Drive from syncing node_modules folder. It need not necessarily involve configuring package.json
2
Answers
It looks like there are a few options suggested over at Excluding node_modules folders from syncing with Google Drive.
Replacing node_modules with a symbolic link looks to be the simplest.
I know Dropbox has an undocumented method using an alternate file stream that can be done in Windows to avoid syncing certain folders. I use this batch script to set the alternate file stream:
I don’t think it’s possible to configure package managers like that. The only reason I purchased Insync was so my
node_modules
folders would not be synced to cloud services like Google drive or Dropbox.Insync supports ignore rules: https://www.insynchq.com/i/features/ignore-rules
Insync works very well. Overall the experience is much better than having
node_modules
constantly and needlessly syncing to the cloud.Sometimes the sync gets a little janky after removing or adding a whole bunch of files suddenly (like
npm install
). Other times git gets confused because files seem like they were modified, but they were just deleted and recreated by sync. (A simplegit add .
resolves this.)Also at first the Insync UI can be a little confusing to get set up correctly. There are just a lot of features I don’t need like two-way vs. one-way cloud sync. But once it’s set up, it works automatically. So you can pretty much forget about it.
A bonus feature of Insync is I can move my git projects outside the folder (and even drive) limitations dictated by Google Drive/Dropbox. For example:
My git projects are synced to
c:dropboxp
Insync lets me work with my projects from
s:p
(I think a bare drive likep:
is also possible.)(I configure Dropbox not to sync
c:dropboxp
so I only have one copy synced locally)Before that, I was using this script to tell Dropbox not to sync
node_modules
folders. But it only applies to existing folders, so must be repeated if newnode_modules
folders are created:ignore_node_modules.sh
See this question for more details about the script above: https://stackoverflow.com/a/69655523/117030 (I used git-bash for windows, thus the mix of bash and powershell.)