Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clearing the Cache of your React Native Project
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.63 - watchman watch-del-all && rm -rf node_modules && npm install && rm -rf /tmp/metro-* && npm run start --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache
@HunterMeyer

This comment has been minimized.

Copy link

@HunterMeyer HunterMeyer commented Apr 8, 2017

Thanks for this. Though I think you want npm cache clean.

@jarretmoses

This comment has been minimized.

Copy link
Owner Author

@jarretmoses jarretmoses commented Apr 14, 2017

Good catch thanks!

@abdurrahmanekr

This comment has been minimized.

Copy link

@abdurrahmanekr abdurrahmanekr commented May 11, 2017

Thanks

@leabdalla

This comment has been minimized.

Copy link

@leabdalla leabdalla commented Jul 9, 2017

maybe you could also remove the build folder? is this a good idea?

@e2goon

This comment has been minimized.

Copy link

@e2goon e2goon commented Jul 18, 2017

wow!! gode code!!

@jarretmoses

This comment has been minimized.

Copy link
Owner Author

@jarretmoses jarretmoses commented Jul 26, 2017

Hey @leabdalla do you mean the ios and android builds?

@alxvallejo

This comment has been minimized.

Copy link

@alxvallejo alxvallejo commented Sep 3, 2017

npm ERR! As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead.

@sjones6

This comment has been minimized.

Copy link

@sjones6 sjones6 commented Sep 18, 2017

@alxvallejo : You can add --force to force a cache clear (including in the message from NPM after the quoted bit): npm cache clean --force

@mrsof

This comment has been minimized.

Copy link

@mrsof mrsof commented Sep 25, 2017

My 50cents. Windows and Android version (from react-native root project)
del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache

or

del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & yarn install & react-native run-android

@jarretmoses

This comment has been minimized.

Copy link
Owner Author

@jarretmoses jarretmoses commented Oct 5, 2017

@sjones6 @mrsof thanks for the input will try them out and update!

@kamalkech

This comment has been minimized.

Copy link

@kamalkech kamalkech commented Nov 4, 2017

not working i get some error :

React Native version mismatch.

JavaScript version: 0.50.0
Native version: 0.49.3

Make sure that you have rebuilt the native code. If the problem persists try clearing the Watchman and packager caches with watchman watch-del-all && react-native start --reset-cache.
checkVersions
index.bundle?platform=android&dev=true&minify=false:9761:20

index.bundle?platform=android&dev=true&minify=false:9618:38
loadModuleImplementation
index.bundle?platform=android&dev=true&minify=false:127:12
guardedLoadModule
index.bundle?platform=android&dev=true&minify=false:79:45
_require
index.bundle?platform=android&dev=true&minify=false:64:77
global code
index.bundle?platform=android&dev=true&minify=false:51662:9

@light-fury

This comment has been minimized.

Copy link

@light-fury light-fury commented Nov 6, 2017

@kamalkech Any updates?

I've used react-native@0.50.1 and got same issue.

@slorber

This comment has been minimized.

Copy link

@slorber slorber commented Dec 6, 2017

for RN50 the tmp cache files seems to have a different name

"clear": "rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-*",
@leoskyrocker

This comment has been minimized.

Copy link

@leoskyrocker leoskyrocker commented Dec 27, 2017

Thanks @slorber, you saved my life, clearing the metro caches was necessary.

@khanhtdbse

This comment has been minimized.

Copy link

@khanhtdbse khanhtdbse commented Jan 11, 2018

@kamalkech
Thank for --reset-cache :)

@jarretmoses

This comment has been minimized.

Copy link
Owner Author

@jarretmoses jarretmoses commented Jan 11, 2018

@kamalkech sorry for the delay. I haven't updated this to match recent versions of React Native. I will be doing a revamp of this and testing against more recent versions. Ideally in the future I will be better at keeping this up to date. @slorber thanks for that response, I will update this gist accordingly and give some options per versioning

@mjstelly

This comment has been minimized.

Copy link

@mjstelly mjstelly commented Jan 12, 2018

Watchman readme says the package is deprecated. Does the gist need to be updated?

@baoanhng

This comment has been minimized.

Copy link

@baoanhng baoanhng commented Jan 19, 2018

Save my fecking time. Everytime I installed new package it's been 'undefined undefined'

@zamberform

This comment has been minimized.

Copy link

@zamberform zamberform commented Feb 27, 2018

As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid

it will be::::::::
watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache

@raktec

This comment has been minimized.

Copy link

@raktec raktec commented Mar 12, 2018

very simple to clear cache below code
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res


@nlothian

This comment has been minimized.

Copy link

@nlothian nlothian commented Mar 14, 2018

Note that for me (Ubuntu 16.10) $TMPDIR wasn't set.

@sterswift

This comment has been minimized.

Copy link

@sterswift sterswift commented Mar 28, 2018

Thank you very much, worked for me!

@kleosus

This comment has been minimized.

Copy link

@kleosus kleosus commented Apr 20, 2018

Thank you very much, worked for me too

@ztl8702

This comment has been minimized.

Copy link

@ztl8702 ztl8702 commented May 15, 2018

How does it work on Windows?

@kyungjoongo

This comment has been minimized.

Copy link

@kyungjoongo kyungjoongo commented Jun 7, 2018

How does it work on Windows?

@nzrsrk

This comment has been minimized.

Copy link

@nzrsrk nzrsrk commented Jul 17, 2018

watchman is not an internal and external command how to fix it??

@iLTW1n

This comment has been minimized.

Copy link

@iLTW1n iLTW1n commented Jul 19, 2018

I thought about just deleting the cache, not node_modules

@joshuaturner

This comment has been minimized.

Copy link

@joshuaturner joshuaturner commented Jul 24, 2018

At least with RN 0.56 I also had to run rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/haste-*

@syyam

This comment has been minimized.

Copy link

@syyam syyam commented Jul 28, 2018

just npm cache clean && npm install && npm start -- --reset-cache worked for me

@Dimon70007

This comment has been minimized.

Copy link

@Dimon70007 Dimon70007 commented Aug 7, 2018

no need to call npm install. in RN 0.55 for cleaning js cache just enough:

watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/metro* && rm -rf $TMPDIR/haste-*
@marcioeric

This comment has been minimized.

Copy link

@marcioeric marcioeric commented Aug 15, 2018

Thank you!

@harisanwar64

This comment has been minimized.

Copy link

@harisanwar64 harisanwar64 commented Sep 18, 2018

For React Native (without Expo) use: react-native run-android -- --reset-cache

@nilocoelhojunior

This comment has been minimized.

Copy link

@nilocoelhojunior nilocoelhojunior commented Sep 28, 2018

Thank you!

@sanderkaz

This comment has been minimized.

Copy link

@sanderkaz sanderkaz commented Oct 5, 2018

Thank you! deleting node_modules & npm install & npm start -- --reset-cache works fine.

@bsaqqa

This comment has been minimized.

Copy link

@bsaqqa bsaqqa commented Oct 16, 2018

Thanks

@yangkezun

This comment has been minimized.

Copy link

@yangkezun yangkezun commented Nov 1, 2018

@harisanwar64 it works for me

@yangkezun

This comment has been minimized.

Copy link

@yangkezun yangkezun commented Nov 1, 2018

@harisanwar64 Thanks

@laurentlemaire

This comment has been minimized.

Copy link

@laurentlemaire laurentlemaire commented Nov 13, 2018

I have tried it all and I'm still facing the "unable to resolve module .... does not exist in the haste module map".
I'm running it on IOS simulator on a Mac, with RN 0.55.2
I've tried:

  • Clearing npm cache
  • Running watchman watch-del-all
  • Removing haste file from temp
  • Removing metro files from temp
  • Removing react files from temp
  • Removing node_modules & install

Any idea?

@onusvishal

This comment has been minimized.

Copy link

@onusvishal onusvishal commented Dec 12, 2018

-bash: clear: rm: command not found

@StephenTANM

This comment has been minimized.

Copy link

@StephenTANM StephenTANM commented Dec 13, 2018

My 50cents. Windows and Android version (from react-native root project)
del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache

or

del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & yarn install & react-native run-android

Thanks!

@kasperpihl

This comment has been minimized.

Copy link

@kasperpihl kasperpihl commented Dec 14, 2018

I had so many issues on clearing the cache. Turns out that the metro bundler and haste map has changed their directory structure. 👎

This is the script I use to clean the cache:
watchman watch-del-all && rm package-lock.json && rm -rf node_modules && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-map-* && npm install

This has costed us DAYS, hope this helps someone :)

@torchhound

This comment has been minimized.

Copy link

@torchhound torchhound commented Dec 16, 2018

Sometimes removing ~/.rncache/ can also help.

@ashishcompwiz

This comment has been minimized.

Copy link

@ashishcompwiz ashishcompwiz commented Dec 18, 2018

go to C:\Users<Username>\AppData\Local\Temp and delete metro-cache .
It will solve your problem

@jskod

This comment has been minimized.

Copy link

@jskod jskod commented Dec 28, 2018

npm cache clean will not clean the cache unless --force flag is passed.

@jetobe95

This comment has been minimized.

Copy link

@jetobe95 jetobe95 commented Jan 17, 2019

thnkssss

@mikebridge

This comment has been minimized.

Copy link

@mikebridge mikebridge commented Feb 7, 2019

For me the haste-map* file is in $TEMP on Windows:

Remove-Item $env:TEMP\haste-map*
@nubwang

This comment has been minimized.

Copy link

@nubwang nubwang commented Feb 19, 2019

Delete everything on the computer

@denisinla

This comment has been minimized.

Copy link

@denisinla denisinla commented Feb 27, 2019

I had so many issues on clearing the cache. Turns out that the metro bundler and haste map has changed their directory structure.

This is the script I use to clean the cache:
watchman watch-del-all && rm package-lock.json && rm -rf node_modules && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-map-* && npm install

This has costed us DAYS, hope this helps someone :)

Thanks for the find! I adjusted your command a bit since I was using yarn.

watchman watch-del-all && rm yarn.lock && rm -rf node_modules && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-map-* && yarn
@kerembalcan

This comment has been minimized.

Copy link

@kerembalcan kerembalcan commented Apr 12, 2019

I had so many issues on clearing the cache. Turns out that the metro bundler and haste map has changed their directory structure.
This is the script I use to clean the cache:
watchman watch-del-all && rm package-lock.json && rm -rf node_modules && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-map-* && npm install
This has costed us DAYS, hope this helps someone :)

@kasperpihl I am facing the same issue now. I didn't read your comment before I run "npm cache clean --force" then suddenly metro bundler's started looking files in my Desktop, not in the project root. I managed to fix path issue by setting project root in metro.config.js but it complains about haste map too. I wonder how did you solve it?

@Jullib

This comment has been minimized.

Copy link

@Jullib Jullib commented Apr 12, 2019

My 50cents. Windows and Android version (from react-native root project)
del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache
or
del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & yarn install & react-native run-android

Why it do not work in my project? (((
I enter these commands in the project folder, it says to me that ""watchman" - not internal or external
command executing a program or batch file".
What am I doing wrong?

@Gregory-Canonne

This comment has been minimized.

Copy link

@Gregory-Canonne Gregory-Canonne commented Apr 22, 2019

the solution is simple :
=> nameToYourProject/ios/build (remove)
=> remove node-modules
=> npm install
=> react-native run-ios
End !

@krozett

This comment has been minimized.

Copy link

@krozett krozett commented Jun 7, 2019

Even simpler solution:
npm uninstall -g react-native-cli
rm -rf ~/Projects/react-native-*
echo "127.0.0.1 facebook.github.io" > /etc/hosts

Leave RN in the trash where it belongs. You'll thank me.

@firofame

This comment has been minimized.

Copy link

@firofame firofame commented Jun 18, 2019

This is what works for me:
watchman watch-del-all && rm -f yarn.lock && rm -rf node_modules && yarn && yarn start --reset-cache

@tereshchenkoartyom94

This comment has been minimized.

Copy link

@tereshchenkoartyom94 tereshchenkoartyom94 commented Jun 19, 2019

Even simpler solution:
npm uninstall -g react-native-cli
rm -rf ~/Projects/react-native-*
echo "127.0.0.1 facebook.github.io" > /etc/hosts

Leave RN in the trash where it belongs. You'll thank me.

This is the best solution!

@arled

This comment has been minimized.

Copy link

@arled arled commented Jun 21, 2019

Thank me later or not at all. Either way it's all good:
npm start -- --reset-cache

@gausam

This comment has been minimized.

Copy link

@gausam gausam commented Jul 9, 2019

Thank me later or not at all. Either way it's all good:
npm start -- --reset-cache

@arled Thank you 💥

@yagoazedias

This comment has been minimized.

Copy link

@yagoazedias yagoazedias commented Jul 10, 2019

@mrsof tips to clean cache worked to me

@jbburf

This comment has been minimized.

Copy link

@jbburf jbburf commented Aug 2, 2019

Me as well, thanks @HunterMeyer!

@jarretmoses

This comment has been minimized.

Copy link
Owner Author

@jarretmoses jarretmoses commented Aug 2, 2019

Sorry everyone obviously this has become out of date. I will look through the comments and make an updated version. Thanks for sharing!

@waqaramjad

This comment has been minimized.

Copy link

@waqaramjad waqaramjad commented Oct 24, 2019

for RN50 the tmp cache files seems to have a different name

"clear": "rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-*",

is that command is for windows ?

@SanjulaD

This comment has been minimized.

Copy link

@SanjulaD SanjulaD commented Nov 3, 2019

can you guys tell me where to type this command in my terminal(path)??

@jotapepinheiro

This comment has been minimized.

Copy link

@jotapepinheiro jotapepinheiro commented Nov 5, 2019

#!/bin/sh
BLUE='\033[0;34m'
NC='\033[0m'

echo "${BLUE}==>1. Refresh watchman${NC}"
watchman watch-del-all

echo "${BLUE}==>2. Remove cache and node_module${NC}"
rm -rf $TMPDIR/react-* &&
rm -rf $TMPDIR/metro-bundler-cache-* &&
rm -rf node_modules/ &&
yarn cache clean

echo "${BLUE}==>3. Re-install libraries${NC}"
yarn install &&
react-native link &&
yarn start -- --reset-cache

echo "${BLUE} Reset successful!${NC}"
@gilshaan

This comment has been minimized.

Copy link

@gilshaan gilshaan commented Nov 11, 2019

Clean cache

rm -rf $TMPDIR/react-; rm -rf $TMPDIR/haste-; rm -rf $TMPDIR/metro-*; watchman watch-del-all

@kroska

This comment has been minimized.

Copy link

@kroska kroska commented Nov 18, 2019

Thank me later or not at all. Either way it's all good:
npm start -- --reset-cache

@arled Thank you 💥

tks!!

@JungDonggun

This comment has been minimized.

Copy link

@JungDonggun JungDonggun commented Nov 25, 2019

Thank you 😙

@developerantoniosousa

This comment has been minimized.

Copy link

@developerantoniosousa developerantoniosousa commented Dec 31, 2019

Thanks!!

@mmarquezv

This comment has been minimized.

Copy link

@mmarquezv mmarquezv commented Jan 9, 2020

For React Native (without Expo) use: react-native run-android -- --reset-cache
That did the trick. Thanks!

@tomlobato

This comment has been minimized.

Copy link

@tomlobato tomlobato commented Jan 12, 2020

#!/bin/sh
BLUE='\033[0;34m'
NC='\033[0m'

echo "${BLUE}==>1. Refresh watchman${NC}"
watchman watch-del-all

echo "${BLUE}==>2. Remove cache and node_module${NC}"
rm -rf $TMPDIR/react-* &&
rm -rf $TMPDIR/metro-bundler-cache-* &&
rm -rf node_modules/ &&
yarn cache clean

echo "${BLUE}==>3. Re-install libraries${NC}"
yarn install &&
react-native link &&
yarn start -- --reset-cache

echo "${BLUE} Reset successful!${NC}"

Nice, tks @jotapepinheiro !
Why the 'react-native link' is needed here?

@andresprogra

This comment has been minimized.

Copy link

@andresprogra andresprogra commented Jan 15, 2020

watchman watch-del-all && rm -rf node_modules/ && npm cache clean --force&& npm install && npm start -- --reset-cache

@safarishi

This comment has been minimized.

Copy link

@safarishi safarishi commented Feb 10, 2020

I had so many issues on clearing the cache. Turns out that the metro bundler and haste map has changed their directory structure. 👎

This is the script I use to clean the cache:
watchman watch-del-all && rm package-lock.json && rm -rf node_modules && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-map-* && npm install

This has costed us DAYS, hope this helps someone :)

What's the meaning for the follow command "rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-map-*" actually mean?

@sakillin

This comment has been minimized.

Copy link

@sakillin sakillin commented Feb 19, 2020

I just ran into an issue that required figuring out how to purge everything related to a React Native build and I feel all the pain here. For sanity, I finally went and Dockerized the bundler and pointed the native app at the container just to make sure I wasn't crazy. That helped, since I could at least know that my application was working in theory.

It is very frustrating to have to go to 6 different places to get this reset.

@safarishi
For the command:

rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-map-*
  • rm -rf means to recursively remove all files/folders at the following path
  • $TMPDIR is the environment variable for your systems temporary directory, it isn't the same on every platform
  • $TMPDIR/metro-* means every file/folder that matches with the * wildcard (so metro-foo as well as metro-bar)
  • The && means "run this command as well

So the whole command means to recursively purge any files that start with "metro-" or "haste-map-" from your system's temporary directory.

@the-habu

This comment has been minimized.

Copy link

@the-habu the-habu commented Mar 30, 2020

Even simpler solution:
npm uninstall -g react-native-cli
rm -rf ~/Projects/react-native-*
echo "127.0.0.1 facebook.github.io" > /etc/hosts

Leave RN in the trash where it belongs. You'll thank me.

It's dangerous to go alone, take this: 🖕

@shardick

This comment has been minimized.

Copy link

@shardick shardick commented Apr 11, 2020

Works on Windows 10 & react native >= 0.60

@echo off
echo Deleting metro cache
rd %localappdata%\Temp\metro-cache /s /q 
del %localappdata%\Temp\haste-map*
echo Cleaning build
cd android & gradlew clean & cd .. 
echo Deleting node_modules
rd node_modules /q /s 
echo Cleaning npm cache
npm cache clean --force 
echo Installing modules
npm install
echo Done
@vnshah

This comment has been minimized.

Copy link

@vnshah vnshah commented Apr 19, 2020

Thank me later or not at all. Either way it's all good:
npm start -- --reset-cache

Worked like a charm! Thanks man.

@wikramdas

This comment has been minimized.

Copy link

@wikramdas wikramdas commented Apr 23, 2020

Hey guys hope you all are doing good.
I have a problem in react native app I want to add clear cache option in react native app for users to clear app cache when they want to clear basically my app is wallpapers app.
So kindly help me if it is possible.
Thanks

@disrae

This comment has been minimized.

Copy link

@disrae disrae commented May 19, 2020

Hmmm, not working for me, and I'm not using npm start, but I tried clearing the npm cache and running the watchmen command.

@Jp3rd

This comment has been minimized.

Copy link

@Jp3rd Jp3rd commented May 28, 2020

I just ran into an issue that required figuring out how to purge everything related to a React Native build and I feel all the pain here. For sanity, I finally went and Dockerized the bundler and pointed the native app at the container just to make sure I wasn't crazy. That helped, since I could at least know that my application was working in theory.

It is very frustrating to have to go to 6 different places to get this reset.

@safarishi
For the command:

rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-map-*
  • rm -rf means to recursively remove all files/folders at the following path
  • $TMPDIR is the environment variable for your systems temporary directory, it isn't the same on every platform
  • $TMPDIR/metro-* means every file/folder that matches with the * wildcard (so metro-foo as well as metro-bar)
  • The && means "run this command as well

So the whole command means to recursively purge any files that start with "metro-" or "haste-map-" from your system's temporary directory.

This worked for me, the metro cache file names have changed. I am using RN 0.59

@Carlos767

This comment has been minimized.

Copy link

@Carlos767 Carlos767 commented Jun 4, 2020

So I get:

React Native version mismatch.

JavaScript version: 0.62.2
Native version: 0.59.8

Make sure that you have rebuilt the native code. If the problem persists try clearing the Watchman and packager caches with watchman watch-del-all && react-native start --reset-cache.

construct
[native code]:0

_construct
construct.js.19:9

Wrapper
wrapNativeSuper.js:26:22
```...

________________________
When I run:
MacBook-Pro$ watchman watch-del-all && rm yarn.lock && rm -rf node_modules && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-map-* && yarn

I get:
bash: watchman: command not found

Any ideas on how to fix this?
@akinolu52

This comment has been minimized.

Copy link

@akinolu52 akinolu52 commented Jun 6, 2020

@Carlos767
close your terminal, delete your project node_modules then
npm i && npm start -- --reset-cache

@sebaxf

This comment has been minimized.

Copy link

@sebaxf sebaxf commented Jun 9, 2020

Thank me later or not at all. Either way it's all good:
npm start -- --reset-cache

Thanks!!

@Qisheng-Lu

This comment has been minimized.

Copy link

@Qisheng-Lu Qisheng-Lu commented Jun 22, 2020

Thank you! deleting node_modules & npm install & npm start -- --reset-cache works fine.

what?

@utkalpatel-dev

This comment has been minimized.

Copy link

@utkalpatel-dev utkalpatel-dev commented Jun 30, 2020

I had so many issues on clearing the cache. Turns out that the metro bundler and haste map has changed their directory structure. 👎

This is the script I use to clean the cache:
watchman watch-del-all && rm package-lock.json && rm -rf node_modules && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-map-* && npm install

This has costed us DAYS, hope this helps someone :)

you save my day bro.. I tired every thing but nothing worked and finally your solution rocks

@thatsatul

This comment has been minimized.

Copy link

@thatsatul thatsatul commented Aug 30, 2020

Getting same error.
error: bundling failed: Error: Unable to resolve module @babel/runtime/helpers/interopRequireDefault from <root>/index.android.js: Module @babel/runtime/helpers/interopRequireDefault does not exist in the Haste module map

Yarn add @babel/runtime not working.

react-native start --reset-cache not working.

Uninstalling watchman not working.

Below command is also not working for me.
watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/metro-* && rm -rf node_modules/ && yarn cache clean --force && yarn install && react-native start --reset-cache

React Native Environment Info:
System:
OS: macOS 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
Memory: 82.13 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.3 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5900203
Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.59.9 => 0.59.9
npmGlobalPackages:
react-native-cli: 2.0.1

If there are some other solutions, please suggest. Totally stuck at this problem for 2 days.

@jarretmoses

This comment has been minimized.

Copy link
Owner Author

@jarretmoses jarretmoses commented Sep 5, 2020

Wow this gist has really had traction. I apologize for not keeping this up to date. If anyone would like to provide me with the current standard for clearing your react native cache I can add it to the gist.

@benwinston

This comment has been minimized.

Copy link

@benwinston benwinston commented Sep 6, 2020

Extremely helpful. Facebook needs to hire this guy ASAP.

@comradem

This comment has been minimized.

Copy link

@comradem comradem commented Oct 17, 2020

IDDQD

@Joshmatjjen

This comment has been minimized.

Copy link

@Joshmatjjen Joshmatjjen commented Nov 24, 2020

@jarretmoses Is there a way to create a button to programmatically clear cache in release app... What do u think?

@mstrokin

This comment has been minimized.

Copy link

@mstrokin mstrokin commented Dec 7, 2020

So I get:

bash: watchman: command not found

Any ideas on how to fix this?

@Carlos767 FYI
brew install watchman if you're using brew

@tgvishal

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment