How to Clear Cache in React Native

In this article, I will show you how to clear the cache in React Native. (As of November 2023, latest version)

bash
# Delete watchman cache
watchman watch-del-all

# Delete iOS build files
rm -rf ios/build

# Delete Android build files
rm -rf android/app/build

# Delete node_modules
rm -rf node_modules

# Delete Pods
rm -rf ios/Pods

# Delete Podfile.lock
rm ios/Podfile.lock

# Clear Xcode cache
rm -rf ~/Library/Developer/Xcode/DerivedData

# Install yarn
yarn install

# Install pod
cd ios
pod install

# Clear Android build environment
cd ../android
./gradlew clean

# Restart metro bundler
cd ..
yarn start -- --reset-cache

# Once metro bundler has started, press Control + C to stop it

These commands will help you efficiently clear the cache and reset the environment in React Native, ensuring your app’s smooth development and testing process.

Leave a Reply

Your email address will not be published. Required fields are marked *