More and more developers learn React Native and record their own potholes in the form of notes.
1. The Homebrew installation
brew.sh/
Open the terminal and enter the following code:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy the code
As shown in the figure:
The installation prompts Press RETURN to continue or any other key to abort because validation is required. Press Enter to enter the MAC login password
Node.js and NPM node.js require versions 4.0 and above. Once installed, NPM is available.
2. Install Node. js using NVM, which can be installed using Homebrew
$ brew install nvm
Copy the code
As shown in figure:
If you don’t have a.nvm file, you need to create a.nvm file:
Open the.bash_profileOpen file:
$ open .bash_profile
Copy the code
If you don’t have this file you need to create one:
$ touch .bash_profile
Copy the code
3. Install Watchman and Flow
The following commands monitor file changes and type checking, respectively. The installation is as follows:
$ brew install watchman
Copy the code
$ brew install flow
Copy the code
Install the React Native
$ npm install -g react-native-cli
Copy the code
As shown in figure:
This error is caused by no write permission. Type the following command on terminal:
$ sudo npm install -g react-native-cli
Copy the code
Here is how to initialize a React Native project. It may take a while for the project to be initialized
$react-native Init Project nameCopy the code
$ADB Devices ADB: Command not found: $ADB Devices ADB: Command not found: $ADB Devices ADB: Command not found: $ADB Devices ADB: Command not found
Export ANDROID_HOME= SDK PATH export PATH=$PATH:$ANDROID_HOME/platform-tools Then restart the terminal and check whether the device exists
And then run the project
$ react-native run-android
Copy the code
If the following error occurs, reinstall the environment and it is ok
Reference articles (official documentation is still necessary)
* * 1. In the autumn of god’s blog http://www.csdn.net/article/1970-01-01/2825787 * * * * 2. http://www.lcode.org * *