React native change listening port

2019-01-24 03:20发布

I am using react native android and having face issue to deploy the app on android device. When I run

react-native start, it won't start dev sever on port 8081

enter image description here

I have tried few options mentioned at:

1) https://facebook.github.io/react-native/docs/troubleshooting.html

2) Tried to stop process running at port number 8081, but no success

My question is that can we change the react native dev server port from 8081 (which is default in android howwever the same we can change in ios from AppDelegate.m file) to some thing else or any other approach

Your responses will be highly appreciated. Thanks

8条回答
爷的心禁止访问
2楼-- · 2019-01-24 04:14

Set RCT_METRO_PORT, example:

export RCT_METRO_PORT=8765
查看更多
在下西门庆
3楼-- · 2019-01-24 04:21
export RCT_METRO_PORT=8082
react-native start --port $RCT_METRO_PORT
react-native run-ios

https://facebook.github.io/react-native/docs/troubleshooting#using-a-port-other-than-8081

查看更多
登录 后发表回答