React Native Development
Complete Guide: Setting Up React Native Development Environment on Windows
In this comprehensive guide, we will walk you through the process, providing step-by-step instructions to ensure a smooth setup experience.
Section 1: Installing Node.js and npm
- Open a web browser and go to the official Node.js website: https://nodejs.org
- On the Node.js website, you will see two versions available for download: LTS (Long-Term Support) and Current. It is recommended to download the LTS version for stable and reliable development.
- Click on the “LTS” button to download the LTS version of Node.js. The website should automatically detect your operating system as Windows and provide the appropriate installer.
- Once the installer is downloaded, locate the downloaded file (usually in the Downloads folder) and double-click on it to start the installation.
- The Node.js setup wizard will open. Click “Next” to proceed.
- Read and accept the license agreement, then click “Next”.
- Choose the installation location for Node.js or leave the default location as is. Click “Next”.
- Select the components to install. It is recommended to keep the default selections, which include Node.js runtime and npm package manager. Click “Next”.
- Choose the additional tasks you want the installer to perform. It is recommended to keep the default options selected. Click “Next”.
- Finally, click the “Install” button to start the installation process.
- The installer will now install Node.js and npm on your Windows machine. This may take a few moments.
- Once the installation is complete, click the “Finish” button.
- To verify the installation, open a Command Prompt or PowerShell window and type the following command:
node -v
This command will display the version of Node.js installed on your system. Additionally, you can run the following command to check the version of npm:
npm -v
If both commands display the version numbers without any errors, it means Node.js and npm are successfully installed on your Windows machine.
Section 2: Setting up the Java Development Kit (JDK)
- Visit the Oracle website: https://www.oracle.com/java/technologies/javase-jdk11-downloads.html
- On the Java SE Development Kit 11 Downloads page, scroll down to find the section labeled “Java SE Development Kit 11”. Choose the appropriate installer based on your Windows architecture (32-bit or 64-bit). Click the download link to initiate the download.
- Once the installer is downloaded, locate the downloaded file (usually in the Downloads folder) and double-click on it to start the installation.
- The JDK installer will open. Click “Next” to proceed.
- Read and accept the license agreement, then click “Next.”
- Choose the installation location for the JDK or leave the default location as is. Click “Next”.
- On the “Choose Install Features” screen, you can select the features you want to install. It is recommended to keep the default selections, which include the Development Tools and the Public JRE. Click “Next”.
- On the “Choose Install Location” screen, you can specify the location where the JDK files will be installed. It is recommended to keep the default location or choose a preferred location. Click “Next”.
- The installer will now start installing the JDK. This process may take a few moments.
- Once the installation is complete, you will see a confirmation screen. Click “Close” to exit the installer.
- To verify the JDK installation, open a Command Prompt or PowerShell window and type the following command:
java -version
This command will display the installed JDK version. Additionally, you can run the following command to check the version of the Java Compiler:
javac -version
If both commands display the version numbers without any errors, it means the JDK is successfully installed on your Windows machine.
Section 3: Installing Android Studio and Android SDK
- Visit the official Android Studio website: https://developer.android.com/studio
- Click on the “Download Android Studio” button to start the download.
- Once the download is complete, locate the downloaded file and double-click on it to begin the installation process.
- The Android Studio Setup wizard will open. Click “Next” to proceed.
- Read and accept the terms and conditions, then click “Next”.
- Choose the installation type. It is recommended to select the “Standard” installation, which includes the Android SDK and other necessary components. Click “Next”.
- Select the installation location or keep the default location, then click “Next”.
- Choose the start menu folder for Android Studio or keep the default name, then click “Install”.
- The installation process will begin, and it may take some time to complete.
- Once the installation is finished, click “Next” and then “Finish” to exit the setup wizard.
- After the installation, launch Android Studio. It will prompt you to select the UI theme and suggest downloading additional components. Choose the desired options and click “Next”.
- Android Studio will then download and install the necessary components, including the Android SDK. This process may take some time, depending on your internet speed.
- Once the installation and setup are complete, you will see the Android Studio welcome screen.
- To verify that the Android SDK is installed correctly, click on the “Configure” button at the bottom right corner of the welcome screen, and then select “SDK Manager”.
- The SDK Manager window will open, showing the installed SDK components. Ensure that the necessary Android SDK versions and tools are installed. If any components are missing, select them and click the “Apply” or “Install” button to download and install them.
Section 4: Configuring the Android Device Emulator
- Open Android Studio on your Windows machine.
- From the Android Studio welcome screen, click on “Configure” and select “AVD Manager”.
- The Android Virtual Device (AVD) Manager will open, displaying a list of existing virtual devices (if any).
- Click on the “Create Virtual Device” button to create a new virtual device.
- In the “Select Hardware” screen, choose a device definition that matches your desired virtual device specifications. You can select from various device types, such as Pixel, Nexus, or other popular Android devices. Click “Next”.
- In the “System Image” screen, select the desired Android version for the virtual device. Choose the recommended or latest version, and click “Next”.
- On the “Verify Configuration” screen, you can customize additional settings for the virtual device, such as the device name, screen orientation, and more. Modify the settings according to your preferences, and click “Finish”.
- The AVD Manager will now create the virtual device based on your selections. This process may take a few minutes, as it downloads the necessary system image if it’s not already installed.
- Once the virtual device is created, you will see it listed in the AVD Manager with its name and specifications.
- To launch the Android Emulator, click on the “Play” button (green triangle icon) next to the virtual device in the AVD Manager.
- The Android Emulator will start, and you will see the Android device booting up with the selected Android version.
- Once the Android Emulator is fully loaded, you can interact with it just like a physical Android device.
Section 5: Installing React Native CLI and Creating a New Project
- Open a Command Prompt or Terminal window on your Windows machine.
- Install the React Native CLI globally by running the following command:
npm install -g react-native-cli
This command will download and install the React Native CLI package globally on your system.
3. Once the installation is complete, you can verify the installation by running the following command:
react-native --version
This command will display the installed version of the React Native CLI.
4. Now, navigate to the directory where you want to create your new React Native project using the cd
command. For example:
cd path/to/project-directory
Replace path/to/project-directory
with the actual path to your desired project directory.
5. Once you are in the desired directory, create a new React Native project by running the following command:
npx react-native init YourProjectName
Replace YourProjectName
with the desired name for your project. This command will create a new React Native project with the specified name in the current directory.
6. The project creation process may take a few minutes, as it downloads and sets up the necessary project files and dependencies.
7. Once the project creation is complete, navigate into the project directory using the cd
command:
cd YourProjectName
Replace YourProjectName
with the actual name of your project.
Section 6: Running the React Native App on the Emulator
- Make sure you have set up the Android emulator based on your development environment.
- Open a Command Prompt or Terminal window and navigate to the root directory of your React Native project.
- Run the following command to start the Metro Bundler, which bundles your app’s JavaScript code:
npx react-native start
Keep the Metro Bundler running in the background.
4. For Android:
- Open a new Command Prompt or Terminal window (while keeping the Metro Bundler window open) and navigate to the root directory of your React Native project.
- Run the following command to install and launch your app on the Android emulator:
npx react-native run-android
- The React Native packager will build the app and install it on the running Android emulator. You will see the app running on the emulator.
5. If all goes well, your React Native app will be launched on the emulator, and you can interact with it just like a real device.
Section 7: Set up an editor for React Native development
Setting up Visual Studio Code (VS Code):
- Download and install Visual Studio Code from the official website: https://code.visualstudio.com/
- Launch VS Code and open the Extensions sidebar by clicking the square icon on the left sidebar or by pressing
Ctrl + Shift + X
. - Search for and install the following extensions:
- “React Native Tools” by Microsoft: This extension provides useful features for React Native development, such as IntelliSense, debugging support, and more.
- “ESLint” by Dirk Baeumer: This extension helps with code linting and formatting to ensure clean and consistent code.
4. Once the extensions are installed, you can customize the editor settings to suit your preferences. You can access the settings by clicking on the gear icon in the lower left corner or by pressing Ctrl + ,
.
5. Additionally, it is recommended to install the “Prettier — Code formatter” extension by Prettier for code formatting.
Congratulations! You have successfully done with your React Native development setup. You can now make changes to your code and see them reflected in real-time on the emulator as you continue to develop your app.
If you liked this course syllabus and want to lectures, here are entire courses you may enjoy:
You can connect with me on LinkedIn, or by visiting my website, cdappdeveloper.
What Next?
Well, Next Part We learn a Setting Up React Native on macOS for iOS and Android Development.