|

Dev Log: How to Properly Zip and Backup Your Dev Projects

If you’ve ever tried to move a web project to a thumb drive or upload it to cloud storage, you’ve likely watched in horror as the “Time Remaining” jumped from 2 minutes to 2 hours. The culprit? The infamous node_modules folder.

As developers, our machines are constantly evolving. In this post, we’ll look at why that folder is the “junk drawer” of your project and how to use PowerShell to create clean, lightweight backups that only include what matters.

The node_modules Rule: Don’t Backup, Just Rebuild

It’s a common instinct to want to save everything in your project folder. However, in modern development, node_modules is considered disposable data.

Why you should exclude it:

  • The “Black Hole” Effect: Even a simple React or Vue project can have 30,000+ tiny files in node_modules. Most backup tools (and Windows itself) struggle to process that many small files quickly.
  • Huge Footprint: You’re often backing up 500MB of data that is already safely stored on the npm registry.
  • It’s OS-Specific: Some packages compile “native binaries” when you install them. If you backup a project on Windows and restore it on a Mac, the node_modules folder will likely be broken anyway.

What you MUST backup instead:

You only need two small text files to recreate your entire environment:

  1. package.json: The list of what your project needs.
  2. package-lock.json: The exact “version map” that ensures your project builds the same way every time.

The Restore Command:

If you lose your files or move to a new PC, just copy your source code and run:

PowerShell

npm install

How to Zip Your Project (Excluding the Junk)

When you need to send your code to a colleague or create a manual archive, you want a ZIP file that includes your code but ignores .git history and node_modules.

Method 1: The “Git Way” (The Gold Standard)

If you use Git, this is the fastest way to get a “clean” export. It zips only the files Git is actually tracking.

PowerShell

git archive -o project-clean-backup.zip HEAD

Method 2: Using 7-Zip (The Pro Choice)

If you have 7-Zip installed, you can use its powerful exclusion flags. This is much faster than the built-in Windows “Send to Compressed Folder” option.

PowerShell

7z a -tzip backup.zip . -xr!node_modules -xr!.git
  • -xr!node_modules: Excludes the folder and everything inside it, recursively.

Method 3: Standard PowerShell (No Extra Tools)

If you don’t have Git or 7-Zip, you can use this script. It gathers all items except the ones you name, and then zips them.

PowerShell

$files = Get-ChildItem -Path . -Exclude "node_modules", ".git"
Compress-Archive -Path $files -DestinationPath project-backup.zip

Summary Table: Which Zipping Method to Use?

ScenarioBest ToolWhy?
You use Gitgit archiveSmallest file; respects your .gitignore automatically.
You want Speed7-ZipHandles large projects much faster than Windows.
No tools installedPowerShellBuilt-in to every Windows machine.

By keeping your backups focused on your source code rather than your dependencies, you’ll save disk space, bandwidth, and a lot of frustration.