React Native Cheat Sheet: Essential Commands for Development

🔧 Basic Build & Run Commands

CommandDescription
npx react-native run-androidRun the Android app
npx react-native run-iosRun the iOS app (Mac only)
npx react-native startStart the Metro Bundler (Development server)
npx react-native doctorCheck environment setup and troubleshoot issues
cd android && ./gradlew cleanClean the Android build cache
npx react-native-clean-projectClear the entire project cache and builds

🔥 Debugging & Logs

CommandDescription
npx react-native log-androidView Android device logs
npx react-native log-iosView iOS device logs
adb reverse tcp:8081 tcp:8081Connect the Metro server to a USB-connected Android device
adb devicesList all connected Android devices

📦 Package Management (npm / yarn)

CommandDescription
npm install <package-name>Install a package
npm uninstall <package-name>Uninstall a package
npx react-native link <package-name>Link native modules
npm updateUpdate all packages to their latest versions

🚀 Release Build Commands (Android)

CommandDescription
cd android && ./gradlew assembleReleaseBuild the Android release APK
cd android && ./gradlew bundleReleaseBuild an AAB file for the Google Play Store
npx jetifyMigrate to AndroidX (maintain compatibility)

💡 Commands to Fix Common Issues

Bash
# Clear cache and resolve build issues
rm -rf node_modules
npm cache clean --force
npm install
cd android && ./gradlew clean

# Reset iOS Simulator (Mac only)
xcrun simctl erase all

# Force reboot Android Emulator
adb reboot

댓글

이 블로그의 인기 게시물

How to Open, Set, and Save Environment Variables (Windows, macOS, Linux)

My Experience Publishing a React Native App as an iOS Developer

How to Fix Auto Layout Constraint Conflicts and Spacing Issues (Question, Image, and Options)