美文网首页
Mac 搭建 React Native -2018

Mac 搭建 React Native -2018

作者: 大嵩的格洛米 | 来源:发表于2021-07-09 17:19 被阅读0次

    必须安装的软件
    Homebrew,Node.js,Watchman,react-native-cli
    Homebrew
    是什么?
    Mac 系统的包管理器,用于安装 Node,Watchman 等其他软件,并且可以统一管理。
    React Native 通过 Watchman 来监视代码文件的改动并适时进行编译

    image.png
    1、 安装 homebre

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

    2、 配置node国内镜像

    (1)修改 下载仓库为淘宝镜像

    npm config set registry https://registry.npm.taobao.org --global

    如果要发布自己的镜像需要修改回来

    npm config set registry https://registry.npmjs.org/

    (2) npm config set disturl https://nodejs.org/dist/ --global

    是否配置成功,请使用下面命令

    npm config get registry

    npm config get disturl

    查看npm全部配置

    npm config get

    $brew install watchman

    3、Yarn、React Native的命令行工具(react-native-cli)

    Yarn是Facebook提供的替代npm的工具,可以加速node模块的下载。

    React Native的命令行工具用于执行创建、初始化、更新项目、运行打包服务(packager)等任务。

    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

    4、添加 yarn (react-native依赖管理工具)

    yarn add react-native # facebook.github.io/react-native/docs/image.html 看官网最新是哪个版本 yarn add react@16.3.1

    5、工程根目录 使用命令(这个会很慢很慢,取决你的网络)

    npm install/yarn install(最好使用yarn install)

    6、react-native (启动 本地Node服务,方便实时用nodo.js去解析ES6的代码 -> main.bundle.js)

    8、重新 启动RN服务问题

    凡是遇到 终端命令错误等的问题,记得先 彻底关闭 终端,在去执行,可能就好了。

    或者

    查看Node.js服务运行进程命令

    lsof -i:8081

    查询结果(node的PID)

    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

    node 9753 srxboys 32u IPv6 0xd47... 0t0 TCP *:sproxyadmin (LISTEN)

    关掉进程(PID)

    kill -9 9753

    相关文章

      网友评论

          本文标题:Mac 搭建 React Native -2018

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