debugreactModeratepending
React Native Metro bundler cache causing stale code
Viewed 0 times
Metro cachereset-cachewatchmanpod installgradlew cleanhot reload broken
macosterminal
Error Messages
Problem
React Native app shows old code after changes. Hot reload doesn't pick up modifications. Sometimes the app crashes with errors that don't match the current source code.
Solution
(1) Clear Metro cache: npx react-native start --reset-cache. (2) Clear watchman: watchman watch-del-all. (3) Clean builds: iOS: cd ios && pod install && cd .. && npx react-native run-ios. Android: cd android && ./gradlew clean && cd .. && npx react-native run-android. (4) Delete node_modules and reinstall: rm -rf node_modules && npm install. (5) Clear Haste module map: rm -rf /tmp/metro-*. (6) Full nuclear clean: rm -rf node_modules ios/Pods ios/build android/app/build && npm install && cd ios && pod install. (7) Check for multiple Metro instances running on same port.
Why
Metro bundler aggressively caches transformed modules for performance. Corrupted cache, stale watchman subscriptions, or native module changes that require a full rebuild can all cause stale code to be served.
Revisions (0)
No revisions yet.