美文网首页
RN:macOS上安装RN

RN:macOS上安装RN

作者: 春暖花已开 | 来源:发表于2020-04-02 19:16 被阅读0次
      1. 安装homebrew
      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
      
      homebrew在安装软件时可能会碰到 /usr/local 目录不可写的权限问题。可以使用下面的命令修复:
      sudo chown -R `whoami` /usr/local
      
      1. 安装node
      brew install node
      
      1. 切换源
      npm config set registry https://registry.npm.taobao.org --global
      npm config set disturl https://npm.taobao.org/dist --global
      
      1. 安装yarn(Yarn是 Facebook 提供的替代 npm 的工具,可以加速 node 模块的下载。)
      npm install -g yarn react-native-cli
      
      1. 设置yarn的源
      yarn config set registry https://registry.npm.taobao.org --global
      yarn config set disturl https://npm.taobao.org/dist --global
      
      1. 安装watchman
      brew install watchman
      
      以上基本上就把RN给搞好了。

    • a. 创建工程
      react-native init ProjectName
      
    • b. 进入rn根文件路径,启动模拟机运行
      react-native run-ios
      
      或设置默认模拟机机型
      react-native run-ios --simulator "iPhone 8"
      
    • c. 模拟机启动失败,配置模拟机
      sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/
      

    参考
    RN 安装步骤
    https://reactnative.cn/docs/getting-started

    相关文章

      网友评论

          本文标题:RN:macOS上安装RN

          本文链接:https://www.haomeiwen.com/subject/srrfphtx.html