react-native 启动报错
npm start
react-native run-android
1.Could not connect to development server(连接不到开发的服务器。)
1.确保包服务器在运行 (npm start)打开(http://localhost:8081/index.android.bundle?platform=android)
1.1 Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class. Run CLI with --verbose flag for more details.verbose flag for more details.
解决:node版本太高,nvm use XXX换成低版本
1.2 bundling failed: Error: Unable to resolve module `react-native-screens` from XXXX
解决:npm install --save react-native-gesture-handler react-native-reanimated react-native-screens
2.确保你的设备或者模拟器连接着电脑,并且手机打开了USB调试模式,然后在cmd中运行adb devices来查看已经连接好的设备列表
3.确保飞行模式是关闭的
4.如果是使用真机来开发,输入 adb reverse tcp:8081 tcp:8081 来检查设备
5.输入IP:8081(菜单键 - Dev Settings - Debug server host & port for device( cmd ipconfig IPV4地址:8081))
2. 端口占用
8081端口占用cmd
netstat -aon |findstr "8081" 查询pid值
tasklist|findstr"pid值" 查询占用进程并关闭
3. Task :react-native-gesture-handler:compileDebugJavaWithJavac FAILED
npm i jetifier
npx jetify
yarn(npm install)