Fresh Command
The buddy fresh command performs a clean reinstallation of all npm dependencies, removing existing node_modules and lock files before installing fresh copies.
Basic Usage
buddy fresh
Command Syntax
buddy fresh [options]
Options
| Option | Description |
|---|---|
-p, --project [project] | Target a specific project |
--verbose | Enable verbose output |
What Happens
The fresh command performs these steps in order:
- Removes all
node_modulesdirectories - Removes lock files (
bun.lockb, etc.) - Clears package manager caches
- Installs all dependencies fresh
Interactive Confirmation
By default, fresh asks for confirmation:
$ buddy fresh
? This will remove and reinstall all dependencies. Continue? (y/N)
Skip Confirmation
buddy fresh --force
# or
buddy fresh --no-interaction
Examples
Fresh Install with Verbose Output
buddy fresh --verbose
Fresh Install for Specific Project
buddy fresh -p my-project
CI/CD Usage
buddy fresh --no-interaction
Use Cases
Resolving Dependency Conflicts
When you encounter dependency resolution issues:
buddy fresh
After Merging Branches
After merging a branch with significant dependency changes:
git pull origin main
buddy fresh
Updating Lock Files
To regenerate lock files with the latest compatible versions:
buddy fresh
Clearing Corrupted Caches
When experiencing strange behavior from cached packages:
buddy fresh --verbose
After Changing Bun/Node Version
When you've upgraded your JavaScript runtime:
buddy fresh
Comparison with Clean
| Command | Removes Dependencies | Reinstalls |
|---|---|---|
buddy clean | Yes | No |
buddy fresh | Yes | Yes |
Performance
The fresh command may take several minutes depending on:
- Number of dependencies
- Network speed
- Package manager cache state
For faster subsequent installs, Bun caches packages locally.
Troubleshooting
Installation Fails After Clean
If installation fails after cleaning:
# Check for sufficient disk space
df -h
# Verify network connectivity
ping registry.npmjs.org
# Try with verbose output
buddy fresh --verbose
Permission Errors
# Fix ownership
sudo chown -R $(whoami) .
# Retry
buddy fresh
Specific Package Fails
If a specific package fails to install:
# Try installing dependencies manually
bun install
# Check the package's repository for known issues
Lock File Conflicts
If you have conflicts in lock files:
# Remove conflicting lock files
rm bun.lockb package-lock.json yarn.lock pnpm-lock.yaml
# Fresh install
buddy fresh
Best Practices
When to Use Fresh
- After major dependency updates
- When experiencing unexplained build errors
- After merging branches with dependency changes
- When switching between branches with different dependencies
When NOT to Use Fresh
- For routine development (use
buddy installinstead) - When you need to preserve exact lock file versions
- In production deployments (use
buddy installwith lock file)
Related Commands
- buddy clean - Remove dependencies without reinstalling
- buddy install - Install dependencies
- buddy upgrade - Upgrade dependencies