Repository: create-react-app
Issue: Option to specify an environment variable specifically for create-react-app's dev and test mode PORT
Labels: issue: proposal,needs triage

### Is your proposal related to a problem?

<!--
  Provide a clear and concise description of what the problem is.
  For example, "I'm always frustrated when..."
-->

A tiny, but consistently frustrating issue for me and many many devs out there is that the `PORT` env var is shared for a lot of things. If you have a classic split rails backend and react frontend, you can't reasonably easily start them by script. There are ugly and fragile options. When running things manually, its a minor annoyance, I have to wait to start the backend, then come back and run the react scripts start command to manually tell it "yeah, sure just use damn port 3001, that's fine!".

Most recently, this was a hassle for me when setting up proper end-to-end tests for co2trackers with cypress. I have to hardcode things, and its still fragile as hell.

### Describe the solution you'd like

<!--
  Provide a clear and concise description of what you want to happen.
-->

[There's a comment in the code about cloud9, so hopefully this doesn't interact poorly](https://github.com/facebook/create-react-app/blob/main/packages/react-scripts/scripts/start.js#L55).

Add another line of code under the line for selecting `DEFAULT_PORT` like so:
```
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
const ALTERNATE_REQUESTED_PORT = (process.env?.CRA_SPECIFIC_START_PORT && parseInt(process.env?.CRA_SPECIFIC_START_PORT, 10))
```
...then later:

```
    if (ALTERNATE_REQUESTED_PORT !== undefined) {
        console.log(`Found CRA_SPECIFIC_START_PORT: ${ALTERNATE_REQUESTED_PORT}. using...`);
        return choosePort(HOST, ALTERNATE_REQUESTED_PORT);
    }
    // We attempt to use the default port but if it is busy, we offer the user to
    // run on a different port. `choosePort()` Promise resolves to the next free port.
    return choosePort(HOST, DEFAULT_PORT);
```

### Describe alternatives you've considered

<!--
  Let us know about other solutions you've tried or researched.
-->

Alternatively, cra could use a command line param. Personally, I tend to prefer command line params over env vars because env vars are the ultimate global variable. They tend to lead to problems exactly like this 😆. I do understand the necessity - the comment about cloud9 suggests this is a reasonable design and I'm not suggesting you change it - otherwise tools have to do odd things like interposing processes. I remember back in the days when I tried to get into static analysis, the clang analyzer had to do some ugly things to interpose and build databases of all the commands executed.

Personally, my programming style is a ton more verbose than this codebase. If it were up to me, I'd also add a few lines to check if `CRA_SPECIFIC_START_PORT` exists, but doesn't seem like an integer, and print a nice warning. I find that going to the extra effort to validate these unlikely cases ends up saving me untold hours down the line when the [unlikely](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt#using_parseint_on_non-strings) inevitably happens.

Yes, I'm the kind of person who checks the return value of `printf` and `fclose`. You'd be amazed what you find.

 
### Additional context

<!--
  Is there anything else you can add about the proposal?
  You might want to link to related issues here, if you haven't already.
-->

I dunno what else to say. This is a small annoyance that affects probably millions of people. Plenty of issues have been filed for it. It's been bugging me for a while and I'm finally getting around to fixing it instead of doing the actual important work I have to do trying to fight the ongoing pandemic 😉🤣. If every programmer in the world fixed at least one of the small little things that bugged them, the whole world would be a better place!