Repository: create-react-app
Issue: Unable to use yarn to create react app inside of an embedded working directory, sent into an error loop
Labels: needs triage,issue: bug report

### Describe the bug

We have a parent repo that all of our apps work underneath of. There is a yarn.lock file that contains all of the linters and prettifiers to keep everything consistent. It is not a monorepo and we are not interested in workspaces.

When trying to create a new react app yarn throws the following error

yarn create react-app newproject

The first error is from yarn
```
Usage Error: The nearest package directory (/../../) doesn't seem to be part of the project declared in /../../newprojct

- If /../../newproject isn't intended to be a project, remove any yarn.lock and/or package.json file there.
- If  /../../newproject is intended to be a project, it might be that you forgot to list marketing in its workspace configuration.
- Finally, if  /../../newproject is fine and you intend marketing to be treated as a completely separate project (not even a workspace), create an empty yarn.lock file in it.
```

So far so good. I simply need to follow the instructions and add a yarn.lock to the newproject directory
following the instructions I run
mkdir newproject
touch ./newproject/yarn.lock

Then I run again
yarn create react-app newproject

the new error:

```
The directory marketing contains files that could conflict:

  yarn.lock

Either try using a new directory name, or remove the files listed above.
```

obviously if I follow these new instructions, it leads me back to the first error

I originally posted this at yarn's github but they suggested that this was actually not a yarn error  https://github.com/yarnpkg/berry/issues/4296#issuecomment-1082758934

Their response


> That's not a bug in yarn; cra should probably detect that the lockfile is empty and tolerate the creation.



### Did you try recovering your dependencies?
Yes

yarn 3.2

### Which terms did you search for in User Guide?



### Environment

<!--
  To help identify if a problem is specific to a platform, browser, or module version, information about your environment is required.
  This enables the maintainers quickly reproduce the issue and give feedback.

  Run the following command in your React app's folder in terminal.
  Note: The result is copied to your clipboard directly.

  `npx create-react-app --info`

  Paste the output of the command in the section below.
-->


Environment Info:

  current version of create-react-app: 5.0.0
  running from /Users/qhenkart/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

  System:
    OS: macOS 12.2.1
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
  Binaries:
    Node: 17.8.0 - /usr/local/bin/node
    Yarn: 3.2.0 - /usr/local/bin/yarn
    npm: 8.5.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 100.0.4896.60
    Edge: Not Found
    Firefox: 97.0.2
    Safari: 15.3
  npmPackages:
    react: Not Found
    react-dom: Not Found
    react-scripts: Not Found
  npmGlobalPackages:
    create-react-app: Not Found
### Steps to reproduce

<!--
  How would you describe your issue to someone who doesn’t know you or your project?
  Try to write a sequence of steps that anybody can repeat to see the issue.
-->

(Write your steps here:)

1. create a directory with a yarn.lock file in it
2. create a directory inside of it and try to use yarn to initialize a cra
3. follow instructions
4. find yourself in error loop

### Expected behavior

cra should accept an empty yarn.lock file or update the error handing as to not direct a user into an error loop

### Actual behavior

cra does not accept an empty yarn.lock file which directly contradicts yarn's resolution messaging

### Reproducible demo

<!--
  If you can, please share a project that reproduces the issue.
  This is the single most effective way to get an issue fixed soon.

  There are two ways to do it:

    * Create a new app and try to reproduce the issue in it.
      This is useful if you roughly know where the problem is, or can’t share the real code.

    * Or, copy your app and remove things until you’re left with the minimal reproducible demo.
      This is useful for finding the root cause. You may then optionally create a new project.

  This is a good guide to creating bug demos: https://stackoverflow.com/help/mcve
  Once you’re done, push the project to GitHub and paste the link to it below:
-->

Not possible. this occurs before the project is created

I listed the steps above

<!--
  What happens if you skip this step?

  We will try to help you, but in many cases it is impossible because crucial
  information is missing. In that case we'll tag an issue as having a low priority,
  and eventually close it if there is no clear direction.

  We still appreciate the report though, as eventually somebody else might
  create a reproducible example for it.

  Thanks for helping us help you!
-->