ReactNative开发踩坑日记
查端口杀进程
sudo lsof -i :8081
sudo kill -9 63
react-native start --port 9999
1、首先安装nodejs,根据官网的安装就好了 https://reactnative.cn/docs/getting-started/
2、其次采用webstorm开发,比vscode省时省力很多
不然使用vscode会配置很多东西,各种报错
解决办法
1 在 android/app/src/main 目录下创建一个 assets空文件夹
mkdir android/app/src/main/assets
2 在项目根目录运行
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
出现以下错误的解决方式:
error listen EADDRINUSE: address already in use :::8081. Run CLI with --verbose flag for more details.
Error: listen EADDRINUSE: address already in use :::8081
react-native run-android命令改为react-native run-android --port 端口号
当然可以直接运行react-native run-android --port 端口号 这个命令node会自动启动。
之后使用adb命令,映射端口号
adb reverse tcp:9999 tcp:8081
问题解决!
IOS遇到的65问题
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening HelloRn.xcworkspace. Run CLI with --verbose flag for more details.
sudo gem install cocoapods
cd ios
pod install
image.png
清除缓存
yarn start --reset-cache