React Native mainly relies on the following environments:
-
Mac OS X operating system
-
Xcode, version 7.3.0 or higher is recommended.
-
Node.js V6.2.1 or the latest version.
-
watchman和flow。
-
NVM
1. Install xcode, no introduction here
2. Install node.js and open the official website of Node.js and download it directly.
3. Install homebrew, open the Homebrew official website , select simplified Chinese as the language, and follow the documentation steps to install
After the installation is complete, open the terminal and enter the command to initialize Homebrew
. The command is:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
4. Install watchman and flow through brew,
React Native
Package Manager uses the watchman, flow is Facebook
the company type check produced a library, which is likewise React Native
used.
If you encounter problems during installation, you may need to update brew
and related dependencies, using the command line: brew update brew upgrade if something goes wrong, you need to fix the local brew installer, brew doctor can help you find the problem.
After installing Homebrew, run the following commands in sequence (time-consuming):
- brew -v
- brew install watchman
- brew install flow
5. Install react-native-cli command line tool
Next, we install the command line tool that reflects the native language-CLI through NPM. Enter the following command in the MAC terminal, where -g means global installation.
sudo npm install -g react-native-cli
6. Install NVM
Reace Native
Use nvm to manage different node and npm.
6.1 Enter the command in the terminal to install NVM:
git clone https://github.com/creationix/nvm
6.2 Enter nvm file
Enter the following commands in the terminal one by one:
cd nvm /
ls
source nvm.sh
nvm
nvm ls -remote N / A
nvm ls
7, create a reactNative project
After setting up the RN environment, let's create a HelloWorld project.
- First create a
rn_demo
folder named on the desktop - Enter the created folder in the terminal (cd)
-
Create a project (The command to create a project is: react-native init HelloWorld
8. Open App.js programming
When the project is running, you can start programming by opening App.js, and you can run command+R directly after programming.