React Native学习笔记(一)Mac OS X下React Native的环境搭建
本文介绍Mac OS X系统下的React Native环境搭建过程。 1.环境要求: 2.安装过程 $node -v
如果能够显示版本信息,则表明安装成功。 $ brew install watchman
$ brew install flow
3) 通过npm安装react-native-cli命令行工具。 $npm install -g react-native-cli
其中-g这个参数表示全局安装。 $sudo npm install -g react-native-cli
至此环境已经搭建完。我们可以创建一个小Demo来检测一下环境搭建的是否成功。 3.创建React Native工程 react-native init AwesomeProject
4.执行项目工程 $react-native run-ios
2)找到AwesomeProject.xcodeproj文件,然后双击打开,com + R直接运行。 5.可能遇到的问题 /**
* Loading JavaScript code - uncomment the one you want.
*
* OPTION 1
* Load from development server. Start the server from the repository root:
*
* $ npm start
*
* To run on device,change `localhost` to the IP address of your computer
* (you can get this by typing `ifconfig` into the terminal and selecting the
* `inet` value under `en0:`) and make sure your computer and iOS device are
* on the same Wi-Fi network.
*/
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
在上面的注释中有明确的说明,需要将localhost换成本地计算机的ip地址。而且查看的方法也给出了,在终端中输入如下命令: $ ifconfig
然后寻找en0:下的IP地址,完成localhost为本机ip地址的替换。 lsof -n -i4TCP:8081
$ kill -9 90587
其中:这个命令的语法为: $ kill -9 <PID>
可以知道90578为进程的id号。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |