React native change listening port
I am using react native android and having face issues to deploy the app on an android device. When I run
react-native start, it won't start dev server on port
8081
I have tried a few options mentioned at:
https://facebook.github.io/react-native/docs/troubleshooting.html
Tried to stop the 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 a default in android however the same we can change in ios from AppDelegate.m file) to something else or any other approach
Your responses will be highly appreciated. Thanks
Answer
Not sure if this is documented or not[1], you can specify the port via a CLI argument, like this:
react-native start --port 9988
I found it in the source code, and it worked on my local machine :)
https://github.com/facebook/react-native/blob/master/local-cli/server/server.js#L30
[1] This is now documented here: https://facebook.github.io/react-native/docs/troubleshooting#using-a-port-other-than-8081
Related Questions
- → Import statement and Babel
- → should I choose reactjs+f7 or f7+vue.js?
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → .tsx webpack compile fails: Unexpected token <
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → React Native with visual studio 2015 IDE
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
- → How do I determine if a new ReactJS session and/or Browser session has started?
- → Alt @decorators in React-Native
- → How to dynamically add class to parent div of focused input field?