Created
June 8, 2025 17:09
-
-
Save calderaro/48ac397eee542b9e3b0c4e5b092f6154 to your computer and use it in GitHub Desktop.
A clean script for React Native project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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