美文网首页
React Native 在mac下安装环境

React Native 在mac下安装环境

作者: 彬至睢阳 | 来源:发表于2018-01-10 16:36 被阅读0次

1.安装Node.js

地址:https://nodejs.org/en/

2.安装React Native

2.1确认Node.js已经安装

2.2确认Xcode已经安装

在安装React Native之前先安装HomeBrew

步骤:

1.在打开的命令行工具中输入如下语句:

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

执行上面命令后会提示输入系统密码,输入密码后开始下载homebrew,如果此时网速不稳定可能会出现错误提示:curl: (35) Server aborted the SSL handshake。此时需要执行

卸载操作,输入如下命令进行卸载:

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

卸载完成后再次尝试安装。

此时可以在命令行中输入命令brew进行测试,可以看到如下结果,说明安装成功。

HomeBrew安装完成后再终端中使用brew命令安装watchman与flow

:brewinstall watchman

:brewinstall flow

安装完node后建议设置npm镜像以加速后面的过程(或使用科学上网工具)。注意:不要使用cnpm!cnpm安装的模块路径比较奇怪,packager不能正常识别!

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

npm config set disturl https://npm.taobao.org/dist --global

完成之后使用npm安装react-native-cil命令行工具

npm install -g yarn react-native-cli

构建项目

react-native init PropertyFinder

项目名为PropertyFinder

打开 Xcode 项目文件,然后创建并运行。模拟器将会启动并且展示问候语,而且有一个终端弹出,上面是具体信息;这就是 React Native 包,在 node 下运行。不要关闭终端窗口;就然它在后台运行。如果你不小心关了,只需要停下来使用 Xcode 重新运行项目。

参考地址

相关文章

网友评论

      本文标题:React Native 在mac下安装环境

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