Skip to content

Instantly share code, notes, and snippets.

@calderaro
Created June 8, 2025 17:09
Show Gist options
  • Save calderaro/48ac397eee542b9e3b0c4e5b092f6154 to your computer and use it in GitHub Desktop.
Save calderaro/48ac397eee542b9e3b0c4e5b092f6154 to your computer and use it in GitHub Desktop.
A clean script for React Native project
#!/bin/bash
set -e
echo "🧹 Cleaning React Native project..."
# Remove node_modules and lock file
echo "πŸ“¦ Removing node_modules and package-lock.json..."
rm -rf node_modules
rm -f package-lock.json
# Clear Metro and Watchman caches
echo "πŸš‡ Clearing Metro and Watchman caches..."
rm -rf $TMPDIR/metro-*
watchman watch-del-all || true
# Clean iOS build
if [ -d "ios" ]; then
echo "🍏 Removing iOS build artifacts..."
rm -rf ios/Pods
rm -rf ios/build
rm -f ios/Podfile.lock
rm -rf ~/Library/Developer/Xcode/DerivedData
fi
# Clean Android build
if [ -d "android" ]; then
echo "πŸ€– Cleaning Android build artifacts..."
rm -rf android/.cxx
rm -rf android/.gradle
rm -rf android/build
rm -rf android/app/.cxx
rm -rf android/app/build
cd android
./gradlew clean
cd ..
fi
# Reinstall npm dependencies
echo "πŸ” Reinstalling npm packages..."
npm install
# Reinstall CocoaPods
if [ -d "ios" ]; then
echo "πŸ“¦ Installing CocoaPods..."
cd ios
pod install
cd ..
fi
echo "βœ… Clean complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment