React Native Errors

🍱Framework
javascript
react-native
errors

How to deal with build issues when working with React Native

Android build erros

Cleaning the Android build folder often helps:

cd android && ./gradlew clean && cd ..

This was suggested in many GitHub issues like here, here or here.

iOS Run errors

Quick fix

Restarting the packager cache sometimes helps

npm start -- --reset-cache

or if you are using yarn:

yarn start --reset-cache

Proper fix

Doing all of the following will often help when faced with weird errors. Run the commands of each line one after the other (here yarn is used):

watchman watch-del-all
rm -rf ./node_modules
rm -rf $TMPDIR/react-*
yarn cache clean
yarn install

yarn start --reset-cache

react-native run-ios

Or just run the following command which combines all the upper commands in one (execution of the command may take a while):

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

Discuss on TwitterImprove this article: Edit on GitHub

Discussion


Explain Programming

André Kovac builds products, creates software, teaches coding, communicates science and speaks at events.