RN 常用命令

1.常用命令

//删除文件夹
rm -rf 目录名字
//列出被占用的端口列表
lsof -n -i4TCP:8081
//找到与之对应的PID然后删除即可
kill -9 <PID> 		
//重新运行项目 
react-native run-ios/android
//打包命令
npm run bundle-ios

"bundle-ios":"node node_modules/react-native/local-cli/cli.js bundle --entry-file index.ios.js --platform ios --dev false --bundle-output ./ios/bundle/index.ios.jsbundle --assets-dest ./ios/bundle" 

sudo npm install --save react-native-code-push 
sudo npm update --save react-native-gesture-handler
sudo react-native link react-native-gesture-handler
sudo npm install --save react-native-code-push 
sudo react-native link react-native-code-push 
react-native install react-native-code-push 
sudo react-native install react-native-code-push 
sudo npm install --save react-native-code-push -unsafe-perm=true --allow-root --save-dev grunt
npm install react-native-code-push --save

1、Clear watchman watches: watchman watch-del-all. 
2、Delete the node_modules folder: rm -rf node_modules && npm install. 
3、Reset packager cache: rm -fr $TMPDIR/react-* or npm start –reset-cache** 

react-native init BloomBeautyRN --version 0.59.1
"react-native": "0.59.1",

//React Native版本降级
react-native init  --version=0.42.0
npm install --save react-native@0.42   

//更新库引用
npm update jshare-react-native
npm update react-navigation-tabs

//安装react-native-git-upgrade工具模块
$ sudo  npm install -g react-native-git-upgrade

//这样会直接把react native升级到最新版本
$ react-native-git-upgrade

//这样把react native升级到指定的X.Y.Z版本
$ react-native-git-upgrade X.Y.Z

指定运行
react-native run-ios --simulator "iPhone 5"

收到Link
iOS
* 		在XCode中的Project Navigator里,右键点击Libraries ➜ Add Files to [你的工程名]
* 		进入node_modules ➜ react-native-update ➜ ios并选中RCTHotUpdate.xcodeproj
* 		在XCode中的project navigator里,选中你的工程,在 Build Phases ➜ Link Binary WithLibraries 中添加 libRCTHotUpdate.a
* 		继续在Build Settings里搜索Header Search Path,添加$(SRCROOT)/../node_modules/react-native-update/ios
* 		Run your project (Cmd+R)

有时候React Native的项目结构改动较大,此时还需要手动做一些修改,例如从0.130.14版本,或是0.280.29版本

  react-native bundle [参数]
  构建 js 离线包 

  Options:

    -h, --help                   输出如何使用的信息
    --entry-file <path>          RN入口文件的路径, 绝对路径或相对路径
    --platform [string]          ios 或 andorid
    --transformer [string]       Specify a custom transformer to be used
    --dev [boolean]              如果为false, 警告会不显示并且打出的包的大小会变小
    --prepack                    当通过时, 打包输出将使用Prepack格式化
    --bridge-config [string]     使用Prepack的一个json格式的文件__fbBatchedBridgeConfig 例如: ./bridgeconfig.json
    --bundle-output <string>     打包后的文件输出目录, 例: /tmp/groups.bundle
    --bundle-encoding [string]   打离线包的格式 可参考链接https://nodejs.org/api/buffer.html#buffer_buffer.
    --sourcemap-output [string]  生成Source Map,但0.14之后不再自动生成source map,需要手动指定这个参数。例: /tmp/groups.map
    --assets-dest [string]       打包时图片资源的存储路径
    --verbose                    显示打包过程
    --reset-cache                移除缓存文件
    --config [string]            命令行的配置文件路径
复制代码

2.Code push 版本推送

//参考:[https://www.jianshu.com/p/88b54e003027](https://www.jianshu.com/p/88b54e003027)
//发布命令
//正式:
code-push release-react BloomBeautyRN ios --t 1.0.0 --dev false --d Production --des "xxxxxx" --m true
//测试:
code-push release-react BloomBeautyRN ios --t 1.0.1 --dev true --d Staging --des "xxxxxx" --m true
//显示历史版本
code-push deployment history BloomBeautyRN Staging
复制代码
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享