This guide helps you resolve common issues with CopyTree.
Problem: copytree: command not found after installation
Solutions:
-
Check npm global bin path:
npm bin -g # Add this path to your PATH environment variable -
Add to PATH (add to ~/.bashrc or ~/.zshrc):
export PATH="$(npm bin -g):$PATH" source ~/.bashrc # or ~/.zshrc
-
Verify installation:
npm list -g copytree
-
Use npx instead:
npx copytree
Problem: Permission denied during global installation
Solutions:
-
Configure npm prefix:
mkdir ~/.npm-global npm config set prefix '~/.npm-global' echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc source ~/.bashrc npm install -g copytree
-
Use local installation:
npm install copytree npx copytree
Problem: Incompatible Node.js version
Solution:
# Check current version
node --version
# Install Node Version Manager (nvm)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# Install Node.js 20+
nvm install 20
nvm use 20Problem: Configuration errors or validation failures
Solutions:
-
Validate configuration:
copytree config:validate
-
Inspect effective configuration:
copytree config:inspect
Problem: CopyTree can't find configuration
Solutions:
-
Check config location:
ls -la ~/.copytree/ -
Configuration is optional:
# CopyTree works with built-in defaults # Configuration files are optional copytree --version
Problem: Command completes but clipboard is empty
Solutions:
-
Check clipboard functionality:
echo "test" | pbcopy # macOS echo "test" | xclip -selection clipboard # Linux
-
Use display mode to verify:
copytree --display
-
Save to file instead:
copytree --output test.xml
-
Use dry-run to check for errors:
copytree --dry-run
Problem: Output exceeds clipboard or memory limits
Solutions:
-
Use file output:
copytree --output large-project.xml
-
Limit content:
copytree --head 100 --char-limit 5000
-
Use specific profile:
copytree --profile minimal
-
Stream output:
copytree --stream > project.xml
Problem: Output format not as expected
Solution:
# Specify format explicitly
copytree --format json
copytree --format xml
copytree --format treeProblem: "No files found matching criteria"
Solutions:
-
Check current directory:
pwd ls -la -
Use less restrictive profile:
copytree --profile full
-
Debug file selection:
copytree --dry-run
-
Check .copytreeignore:
cat .copytreeignore
Problem: Selecting entire node_modules or unwanted files
Solutions:
-
Use specific profile:
copytree --profile minimal
-
Add exclusions:
# Create .copytreeignore echo "node_modules/" > .copytreeignore echo "dist/" >> .copytreeignore
-
Use filters:
copytree --filter "src/**/*.js"
Problem: --modified or --changes not finding files
Solutions:
-
Verify Git repository:
git status
-
Check Git installation:
git --version
-
Ensure changes exist:
git diff --name-only git diff --name-only main..HEAD
Problem: CopyTree takes too long to run
Solutions:
-
Use specific profile:
copytree --profile api # Instead of --profile full -
Use filters to limit scope:
copytree --filter "src/**/*.js" -
Exclude large directories:
echo "coverage/" >> .copytreeignore echo "build/" >> .copytreeignore
Problem: Process uses too much memory
Solutions:
-
Stream output:
copytree --stream > output.xml -
Limit files processed:
copytree src/ --head 1000
-
Increase Node.js memory:
NODE_OPTIONS="--max-old-space-size=4096" copytree
Clipboard not working:
# Test pbcopy
echo "test" | pbcopy
pbpaste # Should output "test"File permissions:
# Reset permissions
chmod -R 755 ~/.copytreeMissing clipboard support:
# Install clipboard utilities
sudo apt-get install xclip # Debian/Ubuntu
sudo yum install xclip # RedHat/CentOSPath issues:
# Add to ~/.bashrc
export PATH="$HOME/.npm-global/bin:$PATH"Line ending problems:
# Configure Git
git config --global core.autocrlf inputPath translation:
# Use WSL paths
copytree /mnt/c/Users/username/projectCollect debug information for bug reports:
# Version info
copytree --version
node --version
npm --version
# Configuration check
copytree config:validate
# Debug run
DEBUG=copytree:* copytree --dry-run# Clear cache (clears all caches by default)
copytree cache:clear
# Clear specific cache types
copytree cache:clear --transformations
copytree cache:clear --git
copytree cache:clear --profiles
# Check cache location
ls -la ~/.copytree/cache/- GitHub Issues: Report bugs and request features
- Documentation: Check other guides in this documentation
- Examples: Review the profile examples for common patterns
- Check profile name spelling
- Ensure profile file exists in
.copytree/or~/.copytree/profiles/ - Check with
ls .copytree/orls ~/.copytree/profiles/
- Current directory might be empty
- Profile rules might be too restrictive
- Check .gitignore and .copytreeignore
- Run
copytree config:validate - Check JSON syntax in config files
- Ensure all required fields are present