Setting up your environment means installing the tools you need to build and run mobile apps. This helps your computer understand and run your app code.
Environment setup (Node, Watchman, Xcode, Android Studio) in React Native
1. Install Node.js from https://nodejs.org/ 2. Install Watchman (macOS only) using Homebrew: brew install watchman 3. Install Xcode from the Mac App Store (for iOS development) 4. Install Android Studio from https://developer.android.com/studio 5. Set up Android SDK and emulator inside Android Studio 6. Configure environment variables for Android SDK 7. Verify installations by running commands like node -v, watchman -v, xcodebuild -version, and adb version
Node.js lets you run JavaScript code on your computer outside the browser.
Watchman helps watch for file changes to speed up app reloads during development.
node -v
watchman -v
xcodebuild -version
adb version
This simple React Native app shows a message confirming your environment is ready. You can run this app on your phone or emulator to check your setup.
import React from 'react'; import { Text, View } from 'react-native'; export default function App() { return ( <View style={{flex:1, justifyContent:'center', alignItems:'center'}}> <Text>Environment Setup Complete!</Text> </View> ); }
Make sure to restart your terminal or computer after installing tools to update system paths.
For iOS development, Xcode only works on macOS.
Android Studio setup requires downloading SDKs and creating virtual devices (emulators) for testing.
Install Node.js to run JavaScript on your computer.
Use Watchman on macOS to watch file changes faster.
Install Xcode for iOS apps and Android Studio for Android apps.
Verify each tool by checking its version in the terminal.
Practice
Solution
Step 1: Understand the role of Node.js
Node.js allows running JavaScript code on your computer, outside the browser, which is essential for React Native development.Step 2: Identify other tools' purposes
Watchman watches file changes, Xcode is for iOS apps, and Android Studio is for Android apps, but none run JavaScript directly.Final Answer:
Node.js -> Option DQuick Check:
JavaScript runtime = Node.js [OK]
- Confusing Watchman as JavaScript runtime
- Thinking Xcode runs JavaScript
- Assuming Android Studio runs JavaScript
Solution
Step 1: Identify the command for Watchman version
The command to check Watchman version iswatchman --version.Step 2: Recognize other commands check different tools
node -vchecks Node.js,xcodebuild -versionchecks Xcode, andandroid-studio --versionis not a valid command.Final Answer:
watchman --version -> Option CQuick Check:
Watchman version command = watchman --version [OK]
- Using node -v for Watchman
- Trying android-studio --version (invalid)
- Using xcodebuild -version for Watchman
xcodebuild -version after installing Xcode correctly?Solution
Step 1: Understand the command output
The commandxcodebuild -versionoutputs the Xcode version and build number.Step 2: Match output to correct tool
Output mentioning "Xcode" and build version matches Xcode, others show versions of different tools.Final Answer:
Xcode 14.3\nBuild version 14E222b -> Option BQuick Check:
Xcode version command output = Xcode 14.3 Build version 14E222b [OK]
- Confusing Node.js version output with Xcode
- Mixing Watchman output with Xcode
- Expecting Android Studio output from xcodebuild
node -v but get an error saying command not found. What is the most likely cause?Solution
Step 1: Analyze the error message
"command not found" means the system cannot find thenodecommand, usually because Node.js is missing or PATH is incorrect.Step 2: Eliminate unrelated causes
Watchman, Xcode, and Android Studio do not affect thenodecommand availability.Final Answer:
Node.js is not installed or not added to PATH -> Option AQuick Check:
Command not found = missing Node.js or PATH issue [OK]
- Assuming Watchman affects node command
- Thinking Xcode installation affects node
- Blaming Android Studio for node errors
Solution
Step 1: Identify tools needed for iOS and Android
Xcode is required for iOS development, Android Studio for Android, Node.js to run JavaScript, and Watchman to watch file changes on macOS.Step 2: Confirm all tools for full setup
To develop for both platforms, all four tools must be installed and verified.Final Answer:
Node.js, Watchman, Xcode, Android Studio -> Option AQuick Check:
All tools for iOS and Android = Node.js, Watchman, Xcode, Android Studio [OK]
- Skipping Watchman on macOS
- Installing only Xcode or Android Studio
- Forgetting Node.js is essential
Ready to prove it?
Pass the test and this pattern moves unknown
