ReactNative 自定义端口支持 run-android 命令,McAfee 解决方法 [英] ReactNative custom port support for run-android command, McAfee workaround
问题描述
我正在尝试为 Windows 配置 React Native 以进行 Android 应用程序开发,但我无法使用端口 8081,因为它由我的笔记本电脑上的 McAfee 代理使用.我可以在不同的端口 (8090) 上启动 node js 服务器
I am trying to configure react native for windows for android app development but I am unable to use port 8081 as it is used by McAfee agent on my laptop. I am able to start node js server on different port (8090)
react-native start --port=8090
但是当我运行命令时:
react-native run-android
我无法指定端口选项.看起来是用8081硬编码的.
I am unable to specify port option. Looks to be that it is hardcoded with 8081.
无论如何我可以在Windows上为自定义端口(8090)端口启动react-native run-android?我对 reactnative 完全陌生,并按照以下链接在 Windows 上为 android 配置示例 Awesomeproject.
Is there anyway I can start react-native run-android for custom port(8090) port on windows? I am completely new to reactnative and following below link to configure sample Awesomeproject for android on windows.
https://facebook.github.io/react-native/docs/getting-started.html#content
推荐答案
有一个小的解决方案.任何在物理设备(甚至其他)上运行它的人都可以使用不同的端口重新启动他们的 adb 会话.
There is a small work around for this. Anyone running this on a physical device(or even otherwise) can restart their adb session using a different port.
例如.
react-native start --port=1234
在不同的 cmd/终端窗口上.
On a different cmd/terminal window.
react-native run-android
之后我收到了这些消息.
After which I am greeted by these messages.
BUILD SUCCESSFUL
Total time: 22.589 secs
Running C:\SDK/platform-tools/adb -s VY0025160560725694 reverse tcp:8081
tcp:8081
这会在 8081 的默认反向端口上运行它,该端口被 McAfee 阻止.
This runs it on default reverse port of 8081, which is blocked by McAfee.
解决办法:
adb reverse tcp:8081 tcp:1234
注意:您可能需要关闭并重新打开该应用.
Note: You may have to kill and re-open the app.
目前我无法为模拟设备提供答案,因为我的系统上没有安装.但是步骤应该是类似的.
Currently I am unable to provide an answer for an emulated device since I do not have one installed on my system. But the steps should be similar.
这篇关于ReactNative 自定义端口支持 run-android 命令,McAfee 解决方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!