Skip to content

Instantly share code, notes, and snippets.

@mikebridge
Created February 7, 2019 19:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikebridge/c27a5a22e2e91a631f4062191b70a955 to your computer and use it in GitHub Desktop.
Save mikebridge/c27a5a22e2e91a631f4062191b70a955 to your computer and use it in GitHub Desktop.
Clear react-native android caches on windows with powershell
# This assumes that it's in a folder `scripts` beside the `build` folder.
#
# Try to address this error:
#
# Unable to resolve module `@blah/whatever` from `whatever.js`: Module `@blah/whatever` does not exist in the Haste module map
#
# This might be related to https://github.com/facebook/react-native/issues/4968
# To resolve try the following:
# 1. Clear watchman watches: `watchman watch-del-all`.
# 2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
# 3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
# 4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
Remove-Item $env:TEMP\haste-map*
Remove-Item -Recurse -Force -ErrorAction Ignore $env:TEMP\metro-cache
Remove-Item -Recurse -Force -ErrorAction Ignore "$PSScriptRoot\..\build\dist"
# Remove-Item -Recurse -Force -ErrorAction Ignore "$PSScriptRoot\..\node_modules"
yarn cache clean
# ALSO: yarn start --reset-cache
# ALSO react-native run-android -- --reset-cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment