React native 环境

来源:互联网 发布:远程语音软件 编辑:程序博客网 时间:2024/06/06 00:31

-------------------------------------------------------------------------------react native 环境搭建---------------------------------------------------------------

一、安装包管理器

注意:时间稍微长点  @powershell -NoProfile -ExecutionPolicyBypass -Command "iex ((new-objectnet.webclient).DownloadString('https://chocolatey.org/install.ps1'))"&& SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

 

二、安装python 2

choco install python2

choco install python2– n 跳过

 

三、设置镜像

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

npm config setdisturl https://npm.taobao.org/dist --global

 

四、安装react-native命令行工具

npm install -greact-native-cli

yarn facebook提供的npm管理工具

npm install -g yarnreact-native-cli

 

五、创建项目

注意:时间较长

react-native initMyProject

react-native initAwesomeProject

 

六、运行(Packager

react-nativestart

注意:碰到了ERROR Watchertook too long to load的报错,请尝试将这个文件中的MAX_WAIT_TIME值改得更大一些 (文件在node_modules/react-native/目录下)。

七、查看打包脚本

http://localhost:8081/index.android.bundle?platform=android

 

八、运行android

react-native run-android

 

九、调试

打开Chrome 浏览器 F12打开开发者模式

React-native start 更新

十、2

十一、      react-native bundle --platformandroid --dev false --entry-file index.android.js --bundle-outputandroid/app/src/main/assets/index.android.bundle --assets-destandroid/app/src/main/res

十二、      daba

       gradle assembleDebug