Run React Packager on different Port - onlinepractice/react-native GitHub Wiki

How to change the default port for react packager

Background

By default, port 8081 is used by react packager and most of the time this port is either used by other process like anti virus etc or other applications. To change the default port to something else, following these steps:

Port change for ios

  1. Open new terminal, go to the react native project (authentication and run this command (in this case 8088 is our new port) -> $ cd /Users/svaishya75/onlinepractice/react-native/authentication
  2. $ run this command -> $react-native start --port=8088
  3. Open another terminal and Go to the react project folder
  4. update the default port (8081) entry with new port (lets say 8088) in the file node_modules/react-native/React/React.xcodeproj/project.pbxproj
  5. execute the command to run the app on ios simulator -> $ react-native run-ios

Note:

If you encounter an error such as npm WARN locking Error: EACCES while using the React Native CLI, try running the following: sudo chown -R $USER ~/.npm sudo chown -R $USER /usr/local/lib/node_modules

Port change for android

pending to update at later stage.