I can change hostname with REACT_NATIVE_PACKAGER_HOSTNAME env variable but can not find how to change the ports. I googled and found .exprc but it doesn't work for me.
Edited:
Sorry for the confusion but I would like to know how to change port with expo.
6 Answers
In your package.json file change
"start": "expo start" to
"start": "expo start --port 19001" 1npx expo start --port=<YOUR_PORT> You can set the RCT_METRO_PORT environment variable (for Metro) and/or WEB_PORT (for Webpack), e.g.:
RCT_METRO_PORT=11111 WEB_PORT=22222 expo start These seem to be undocumented, however, so use with care.
I spent hours with reading source codes but unable to find the config. I ended up updating startDevServerAsync.js script with the port I wanted. (I admit this is not good but I can't spend more time on just dealing with this)
$ which expo-cli /home/shohey1226/.nvm/versions/node/v14.15.5/bin/expo-cli $ cd ~/.nvm/versions/node/v14.15.5/lib/node_modules/expo-cli/node_modules/xdl/build/start $ sed -i 's/19000/8080/g' startDevServerAsync.js To change the default port, you can create an .exprc file in your project root with
{ "manifestPort": valid port number (e.g. 19002) } You can specify this using the following CLI command:
npx react-native start --port=<YOUR_PORT> as documented here.
1