Installing multiple node directory

I am on Windows 10.

Every time I create a new Foundation project with the Zurb template a new local node-modules directory is created and populated. The are many thousands of files, identical across projects (as far as I can see). I am paranoid about backing up my data and this means differential backups are slow,since the entire directiory is processed. Likewise deleting a project.

I was wondering if there is a way to have a single copy of node-modules and reference it in different projects.

Thanks for any help.

No, this is not possible with a default npm setup. What you may want to try is pnpm which does exactly this but is a different npm client.

Optionally you can exclude node_modules from backups or remove these folders since your local npm setup has also a cache folder where copies of all installed dependencies live.

I’d also recommend just removing node_modules from your backups, these can be pulled down into the other backed up files if you ever have to restore them.

I created just one “foundation new” project using the Zurb Template (let’s call it “foundation”). Then I make a new project directory for each new project and put a copy of the src directory and copies of the config.yml and gulpfile.babel.js files in that new project directory. Modify the paths in the config.yml and gulpfile.babel.js to point to the project’s directories. Then I copy those two files into the “foundation” directory when I’m working on that project and call “foundation watch”.

I actually created a batch file that does the copying and starts “foundation watch” to make it even easier - keep it in the individual project folders and run it per project.

I can only be working on one project at a time but it’s easy, keeps your individual projects intact AND only has one version of the foundation template and avoids creating those millions of node files for each project. I wish I would have thought of it years ago.

@maltmaster did you see my previous post, did it make any sense to you?

Thanks Scott for your reply. I had thought to do something similar and it’s good to know that it can work.

My pleasure @maltmaster. Let me know if you’d like to see the config and batch files I’ve modified/created.