react-native 遇到的错误
记录下在react-native开发中遇到的错误
ReferenceError: Can't find variable: __fbBatchedBridge...
react-native启动用来做JavaScript的代码的服务,是本地的服务,App默认访问的host地址是localhost,运行到真实的设备上面的时候无法访问react-native服务,因此会出现上面的错误。
Android解决方案:
- 对adb的server设置反向代理
adb reverse tcp:8081 tcp:8081
- 更改App内的服务地址
* 摇晃手机
点击菜单键
在电脑上面运行命令
>adb shell input keyevent 82
在dev setting里面即可设置。
ios解决方案:
在AppDelegate.m中修改jsCodeLocation:
..... jsCodeLocation = [NSURL URLWithString:@"http://192.168.31.191:8081/index.ios.bundle?platform=ios&dev=true"]; ....
react-native start 错误
错误信息:
ERROR: Unknown option --no-prettyERROR: Unknown option --no-prettyWatchman: watchman--no-pretty get-sockname returned with exit code 1 ERROR: Unknown option --no-pretty ERROR watchman--no-pretty get-sockname returned with exit code 1 ERROR: Unknown option --no-prettyError: watchman--no-pretty get-sockname returned with exit code 1 ERROR: Unknown option --no-pretty at ChildProcess. (.../fb-watchman/index.js:198:18) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at maybeClose (internal/child_process.js:852:16) at Socket. (internal/child_process.js:323:11) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at Pipe._handle.close [as _onclose] (net.js:492:12)
解决方法:
npm r -g watchman brew update && brew upgradebrew install watchman
关键字:产品经理
版权声明
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处。如若内容有涉嫌抄袭侵权/违法违规/事实不符,请点击 举报 进行投诉反馈!