question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

babel-preset-react-app dependency error - Yarn 3

See original GitHub issue

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

https://github.com/Mezzle/cra-yarn-bug-example

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:15
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

35reactions
llimoscommented, Dec 20, 2021

Add to your .yarnrc.yml:

packageExtensions:
  babel-preset-react-app@*:
    dependencies:
      "@babel/plugin-proposal-private-property-in-object": "*"
3reactions
adamtowerzcommented, Dec 18, 2021

#11751 seems like it will fix this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@babel/preset-react | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
node.js - react-native - warnings setting up basic project
Just in case other people search this error again. For my case, I solve it by updating my yarn packages. npm install -g...
Read more >
Create React App without Create React App - Bits and Pieces
Step by Step · 1. Make sure node is installed in your system · 2. Create project folder and package.json · 3. Install...
Read more >
@babel/preset-react - npm
@babel/preset-react. 7.18.6 • Public • Published 6 months ago. Readme · Code Beta · 6 Dependencies · 7,374 Dependents · 57 Versions ...
Read more >
Troubleshooting | React Navigation
I'm getting an error "Unable to resolve module" after updating to the ... npm install --save-dev metro-react-native-babel-preset ... If you use yarn :....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found