How to clear react native cache?

Abhishek Nalwaya
Jan 4, 2019 · 2 min read

Deleting temporary files and memory hogs and clearing unwanted cache items regularly is a great way to clean your development environment. It makes your environment close to your Continuous integration server.

React-native, iOS, and Android are user-friendly ecosystems, they all use caching to a very large extent to have awesome development experience. It speeds up the developer experience. Developer working on Mobile Development sometimes feel frustrated, as they need to clean the cache when things stop working. So will talk about cleaning your development environment specifically to React Native.

How to clean watchman, npm, react native package cache?

For React Native >= 0.50 and npm > 5

watchman watch-del-all && 
rm -rf $TMPDIR/react-native-packager-cache-* &&
rm -rf $TMPDIR/metro-bundler-cache-* &&
rm -rf node_modules/
&& npm cache clean --force &&
npm install &&
npm start -- --reset-cache

Or if you using Yarn

watchman watch-del-all &&
rm -rf $TMPDIR/react-native-packager-cache-* &&
rm -rf $TMPDIR/metro-bundler-cache-* &&
rm -rf node_modules/ &&
yarn cache clean &&
yarn install &&
yarn start -- --reset-cache

How to reset iOS Simulator or Erase all simulator data ?

To reset the iOS simulator and erase all simulator data go to menu and Hardware -> Erase All Content and Settings

How to clean iOS build ?

To clean the iOS build press Option+Shift+Command+K or go to Xcode menu Product -> Clean Build Folder. This will only clean cache for your current target.

How to reset Android Simulator or Erase all simulator data ?

Open Android Studio then goes to menu Tools -> AVD Manager. Then select the menu in your selected simulator and click on wipe data.

How to clean Android Build Cache

Go to root directly of your react native project and run following commands:

cd android &&
./gradlew cleanBuildCache

Happy Cleaning !!

Abhishek Nalwaya

Written by

Author of three books, latest one is on React Native, Architect at Digital Mckinsey

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade