RN:macOS上安装RN
2020-04-02 本文已影响0人
春暖花已开
-
- 安装homebrew
homebrew在安装软件时可能会碰到/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"/usr/local目录不可写的权限问题。可以使用下面的命令修复:sudo chown -R `whoami` /usr/local -
- 安装node
brew install node -
- 切换源
npm config set registry https://registry.npm.taobao.org --global npm config set disturl https://npm.taobao.org/dist --global -
- 安装yarn(Yarn是 Facebook 提供的替代 npm 的工具,可以加速 node 模块的下载。)
npm install -g yarn react-native-cli -
- 设置yarn的源
yarn config set registry https://registry.npm.taobao.org --global yarn config set disturl https://npm.taobao.org/dist --global -
- 安装watchman
以上基本上就把RN给搞好了。brew install watchman
- a. 创建工程
react-native init ProjectName - b. 进入rn根文件路径,启动模拟机运行
或设置默认模拟机机型react-native run-iosreact-native run-ios --simulator "iPhone 8" - c. 模拟机启动失败,配置模拟机
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/