-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CLI] Changing packager port not supported when running run-ios, run-android #14113
Comments
Related issues: |
As a new user to RN who's work laptop will not let him kill the process running on 8081, this would be super helpful. There also don't seem to be any proper instructions on the workaround for this. Lots of suggestions, none of which have worked for me yet. |
Fix for andriod: #15316 |
@hramos Is this still outstanding for iOS? |
This is still an outstanding issue. I have a patch file which we use to setup both iOS and Android appropriately, but its cumbersome to have to apply it after EVERY yarn add/update. I think I have a good enough grasp on this problem to submit a PR, but before I do, I would like to ask @hramos if my approach is acceptable. Basically, setting the port number via CLI is very difficult because of the vast number of different source files that reference the port number. As such, I am proposing that my PR use an environment variable for setting the port. As an example, to run on port 8088 (instead of the default 8081) you would run Please let me know if this is OK I'll get the PR pulled together ASAP. |
I have a submitted a PR for this issue. PR #16172 adds the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
@hramos any way to speed up the PR review / approval process here. Stale bot is going to close our issue 😬 |
Summary: The pull request adds the `--port` option to `run-ios` allowing a developer to build and launch a react-native app using a single command line like this: ``` react-native run-ios --port 8088 ``` It defaults to the current port 8081. This pull request fixes issue #9145 and issue #14113. This patch also extends `run-android` to properly test and launch the packager with the specified port, extending the work done in PR: ##15316 1. Create a new react-native app, or simply clone this branch and then update your version of react-native using `yarn add file:./path/to/this/fork/of/react-native` 2. run `react-native run-ios --port 8088` 3. watch the packager start on the desired port (8088 in this case) and watch your app in your simulator connect to the packager and launch the app. Closes #16172 Differential Revision: D6612534 Pulled By: shergin fbshipit-source-id: 50af449f5e4c32fb76ba95f4cb7bf179e35526d5
Summary: The pull request adds the `--port` option to `run-ios` allowing a developer to build and launch a react-native app using a single command line like this: ``` react-native run-ios --port 8088 ``` It defaults to the current port 8081. This pull request fixes issue facebook#9145 and issue facebook#14113. This patch also extends `run-android` to properly test and launch the packager with the specified port, extending the work done in PR: #facebook#15316 1. Create a new react-native app, or simply clone this branch and then update your version of react-native using `yarn add file:./path/to/this/fork/of/react-native` 2. run `react-native run-ios --port 8088` 3. watch the packager start on the desired port (8088 in this case) and watch your app in your simulator connect to the packager and launch the app. Closes facebook#16172 Differential Revision: D6612534 Pulled By: shergin fbshipit-source-id: 50af449f5e4c32fb76ba95f4cb7bf179e35526d5
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
This is now fixed, thanks @DaKaZ! |
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
react-native start --port=8088
.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:
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
The text was updated successfully, but these errors were encountered: