react native常用命令

初始化一个RN项目

react-native init ReactNativeProject
初始化一个名字为ReactNativeProject的RN项目

node_modules

cd到项目的根目录,执行下列命令
npm install --force
npm cache clean && npm install
npm start --reset-cache
react-native start --reset-cache

安卓打包

cd到项目的安卓文件夹下,执行下列命令
./gradlew clean
./gradlew assembleRelease

android-start

adb reverse tcp:8081 tcp:8081 && react-native start

查看npm版本

cd到项目的根目录或者直接在命令行,执行下列命令
npm -v

查看当前的 Node 版本

node -v

查看所有全局安装的模块

直接在root根目录执行下列命令
npm list -g

React Native CLI安装

npm install -g react-native-cli
或者使用淘宝npm 镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install -g react-native-cli

利用HomeBrew安装Ruby和cocoaPods

brew install ruby
sudo gem install cocoapods

查看当前React Native的版本

react-native info

查看当前的版本

安装 release 版的应用

cd到项目的安卓文件夹下,执行下列命令
react-native run-android --variant=release

更新npm

npm install -g npm

via usb连接电脑

cd C:\Users\1\AppData\Local\Android\Sdk\platform-tools
adb reverse tcp:8081 tcp:8081

bundle-ios

react-native bundle --entry-file ./index.tsx --bundle-output ./dist/ios/index.ios.bundle --assets-dest ./dist/ios/ --dev false --platform ios

bundle-android

react-native bundle --entry-file index.js --platform android --dev false --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest ./android/app/src/main/res/

生成的默认的package.json

npm init -y

列表清单

npm ls

find the id for the process that is listening on port 8081:

sudo lsof -i :8081

Terminating a process on port 8081

kill -9 <PID>

You can configure the bundler to use a port other than 8081 by using the port parameter:

npx react-native start --port=8088

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • -------------如果你使用的是Mac OS系统,请参照以下步骤----------- 安装前注意: 1)...
    Lucky丶晴阅读 3,596评论 0 3
  • 前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人...
    珍此良辰阅读 6,870评论 3 9
  • 经历了人生中比较重要的考试――高考。那三个月似一匹脱缰的野马,怀着一万种想象憧憬大学。 终于来到了开学的那一天,好...
    橘子皮_supar阅读 4,453评论 0 0
  • 今年十一之前,我从没想过相亲这个话题会一直萦绕在我周围,四五个月没有回家了,想和父母谈谈工作,谈谈理想,谈谈对目前...
    木槑槑呆呆阅读 1,252评论 0 0
  • 好多事情开始都很难,开始了要坚持也很不容易,坚持了很久也不一定就能得到想要的成绩。但是如果不坚持又能怎么样呢? 每...
    MISS言甚阅读 1,283评论 4 0

友情链接更多精彩内容