ReactNative调试

jopen 8年前

1. 缺少模块

根目录, 输入npm install, 会自动安装所需模块.
具体会调用package.json内容, 下载dependencies依赖模块.

{    "name": "ChunyuYuEr",    "version": "0.0.1",    "private": true,    "scripts": { "start": "react-native start" },    "dependencies": { "react-native": "^0.14.2", "react-native-communications": "0.0.6" } }

2. 调试

Ctrl+Command+Z启动调试页Debug in Chrome, 会Chrome进行调试. 使用Command+Alt+J, 可以在控制台看到调试信息.

3. Android运行

启动服务: npm start
启动程序: ./gradlew android:app:installDebug

4. 新建项目

npm install -g react-native-cli  react-native init [AwesomeProject]

5. 启动服务

首先需要保证项目中含有node_modules, 默认项目中都会增加, 或是使用

npm install

找到之后, 在./node_modules/react-native中, 使用

./packager/packager.sh

通过shell脚本, 启动服务.

6. 配置数据源

初始化项目(react-native init [xxx])较慢, 可以通过更新数据源的方式提速.

npm config set registry=http://registry.npm.taobao.org/

配置地址.npmrc.

registry=http://registry.npm.taobao.org/

遇到其他小技巧, 我会继续更新.

来自: http://blog.csdn.net//caroline_wendy/article/details/50107841