You must make sure that your development environment is correctly configured with the appropriate tools and settings before beginning a new React Native project. Here’s a guide to the essential configurations required:
1. Install Node.js
Download the latest LTS version of Node.js from nodejs.org.
Verify the installation with:
node -vnpm -v
2. Install React Native CLI
You need the React Native CLI to create and manage React Native projects.
You can install it globally using npm or Yarn:
npm install -g react-native-cli
3. Install Android Studio (for Android development)
Android Studio is required to build and run React Native applications on Android devices.
Download and install Android Studio from developer.android.com.
During installation, make sure to install the following:
Android SDK
Android Virtual Device (AVD)
Android platform tools
After installation, set up Android’s environment variables:
On macOS/Linux, add the following to your ~/.bash_profile or ~/.zshrc:
export ANDROID_HOME=$HOME/Library/Android/sdkexport PATH=$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH
On Windows, set these paths in System Properties > Environment Variables:
ANDROID_HOME: C:\Users\YourUsername\AppData\Local\Android\Sdk
Add the following to the Path variable:
%ANDROID_HOME%\emulator%ANDROID_HOME%\tools%ANDROID_HOME%\tools\bin%ANDROID_HOME%\platform-tools
4. Set Up the React Native Project
After installing the required tools, you can create a new React Native project using the following command:
npx react-native init MyNewProject
This command will initialize a new React Native project named MyNewProject and automatically install dependencies.
5. Run Your Project
For iOS (macOS only):
cd MyNewProjectnpx react-native run-ios
For Android:
Ensure that an Android emulator is running, or connect a physical Android device.
cd MyNewProject
npx react-native run-android