打开终端
1.下载brew,执行
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
以下为成功安装信息,安装过程中会多次需要return和输入电脑密码
Already up-to-date.
上一句如果提示Already up-to-date表示成功
Brew自动安装程序运行完成
国内地址已经配置完成
初步介绍几个brew命令
本地软件库列表:brew ls
查找软件:brew search google(其中google替换为要查找的软件关键字)
查看brew版本:brew -v 更新brew版本:brew update
现在可以输入命令open ~/.zshrc -e 或者 open ~/.bash_profile -e 整理一下重复的语句(运行 echo $SHELL 可以查看应该打开那一个文件修改)
2.安装node, 执行
brew install node
3.安装watchman,执行
brew install watchman
4.执行
npm install -g react-native-cli
5.在项目根目录下执行
yarn install
6.启动安卓模拟器
7.在项目根目录下执行
yarn dev:rn
浏览器打开输入链接:
https://localhost:8081/rn_temp/index.bundle?platform=android&dev=true
8.执行react-native run-android
或者yarn run:android
或者yarn release:android
(执行命令报错[出现灰色的Run cli with] :就执行 chmod 755 android/gradlew )
9.启动成功
环境搭建过程中还有疑问,具体参考以下链接:
https://taro-docs.jd.com/taro/docs/2.2.13/react-native/#%E5%AE%89%E8%A3%85%E4%BE%9D%E8%B5%96