create-react-app: babel-preset-react-app dependency error - Yarn 3
Describe the bug
When attempting to use create-react-app with yarn 3, running the scripts returns the following error
Error: [BABEL] src/index.tsx: babel-preset-react-app tried to access @babel/plugin-proposal-private-property-in-object, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
Did you try recovering your dependencies?
3.1.1
Which terms did you search for in User Guide?
N/A
Environment
current version of create-react-app: 4.0.3
running from /Users/mez/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app
System:
OS: macOS 12.1
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
Yarn: 3.1.1 - ~/.nvm/versions/node/v14.18.1/bin/yarn
npm: 8.1.2 - ~/.nvm/versions/node/v14.18.1/bin/npm
Browsers:
Chrome: Not Found
Edge: Not Found
Firefox: Not Found
Safari: 15.2
npmPackages:
react: Not Found
react-dom: Not Found
react-scripts: Not Found
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
mkdir foo
cd foo
yarn set version berry
yarn create react-app . --template all
yarn start
Expected behavior
App would start
Actual behavior
Multitude of errors, including the above regarding issue with dependency (others are resolvable by adding the dependencies manually)
Reproducible demo
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 16
- Comments: 15 (2 by maintainers)
Commits related to this issue
- 警告を解決 Refs: https://github.com/facebook/create-react-app/issues/11793 — committed to blue32a-sandbox/testing-technique-practice-react by blue32a a year ago
Add to your .yarnrc.yml:
Hi. How is that CRA is not maintained anymore? You are writing in CRA issues list 😄 Isn’t this just some advertisement of the Vite project? 😄
One of your dependencies, babel-preset-react-app, is importing the “@babel/plugin-proposal-private-property-in-object” package without declaring it in its dependencies. This is currently working because “@babel/plugin-proposal-private-property-in-object” is already in your node_modules folder for unrelated reasons, but it may break at any time.
babel-preset-react-app is part of the create-react-app project, which is not maintained anymore. It is thus unlikely that this bug will ever be fixed. If you are starting a new project, you may consider using maintained alternatives such as Vite (https://vitejs.dev/) instead.
Add “@babel/plugin-proposal-private-property-in-object” to your devDependencies to work around this error. This will make this message go away.
How to resolve it
#11751 seems like it will fix this.
Added this to my
.yarnrc.yml
fileSeems to have resolved it
In addition to what @llimos said, you also need to run
yarn install
afterwards to update youryarn.lock
file with this change.Is there a temporary fix for this, it seems I cannot use CRA with yarn workspaces currently
Thanks! #11751 is added to 5.0.1 milestone