Skip to content

[CLI] Changing packager port not supported when running run-ios, run-android #14113

Closed
@hramos

Description

@hramos

Description

It is not currently possible to launch an iOS or Android app and have it connect to a port other than the default of 8081. While it is possible to separately start the packager on a custom port, e.g. react-native start --port=8088, the above two commands are hardcoded to always attempt to start a packager on 8081.

This is troublesome on systems where port 8081 is already in use, as is the case with McAfee AV. Killing the process is not an option in this case.

Reproduction Steps and Sample Code

  1. Run react-native start --port=8088.
  2. Observe that packager is now running on port 8088:
┌────────────────────────────────────────────────────────────────────────────┐ 
│  Running packager on port 8088.                                            │ 
│                                                                            │ 
│  Keep this packager running while developing on any JS projects. Feel      │ 
│  free to close this tab and run your own packager instance if you          │ 
│  prefer.                                                                   │ 
│                                                                            │ 
│  https://github.com/facebook/react-native                                  │ 
│                                                                            │ 
└────────────────────────────────────────────────────────────────────────────┘ 
  1. Launch the iOS or Android app using react-native run-ios, react-native run-android.

If port 8081 is available, the run* command will launch another packager process on port 8081. If the port is not available, you will see the following error:

Port 8081 already in use, packager is either not running or not running correctly

This prevents the developer from launching the app, and effectively makes it so that React Native can only be developed on systems where port 8081 is available.

Solution

We still want run-ios and run-android to launch the packager if none is running, but we cannot assume the packager will always run on port 8081. We can add a port option to the CLI when run-ios or run-android are used.

We also need to update the iOS template as it has a hardcoded check on whether the packager is running on port 8081.

Finally, we need to make sure that once the app launches, it can successfully connect to whatever port is being used. This may require updates to the iOS, Android templates.

Additional Information

  • React Native version:
$ react-native --version
react-native-cli: 2.0.1
react-native: 0.44.0
  • Platform: iOS, Android
  • Development Operating System: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Help Wanted :octocat:Issues ideal for external contributors.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions