Skip to content

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

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

Closed
Mezzle opened this issue Dec 17, 2021 · 15 comments · May be fixed by #11751
Closed

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

Mezzle opened this issue Dec 17, 2021 · 15 comments · May be fixed by #11751
Labels
contributions: up for grabs! dependencies Pull requests that update a dependency file issue: bug report
Milestone

Comments

@Mezzle
Copy link

Mezzle commented Dec 17, 2021

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

@raix raix added dependencies Pull requests that update a dependency file and removed needs triage labels Dec 18, 2021
@raix raix added this to the 5.0.1 milestone Dec 18, 2021
@raix
Copy link
Contributor

raix commented Dec 18, 2021

Thanks @Mezzle for reporting, we likely need to add @babel/plugin-proposal-private-property-in-object in the babel-preset-react-app package as a dependency in package.json

@adamtowerz
Copy link

#11751 seems like it will fix this.

@raix raix linked a pull request Dec 19, 2021 that will close this issue
@kevingilbert100
Copy link

+1

@raix
Copy link
Contributor

raix commented Dec 20, 2021

Thanks! #11751 is added to 5.0.1 milestone

@kevingilbert100
Copy link

Is there a temporary fix for this, it seems I cannot use CRA with yarn workspaces currently

@llimos
Copy link

llimos commented Dec 20, 2021

Add to your .yarnrc.yml:

packageExtensions:
  babel-preset-react-app@*:
    dependencies:
      "@babel/plugin-proposal-private-property-in-object": "*"

@quisido
Copy link

quisido commented Dec 27, 2021

In addition to what @llimos said, you also need to run yarn install afterwards to update your yarn.lock file with this change.

@WegDamit
Copy link

why not just "yarn add @babel/plugin-proposal-private-property-in-object" ?

@quisido
Copy link

quisido commented Jan 13, 2022

why not just "yarn add @babel/plugin-proposal-private-property-in-object" ?

Because that doesn't resolve the warning. That adds it to your package.json, which - as the error states - makes the import ambiguous and unsound.

@msotho
Copy link

msotho commented Jan 26, 2022

Added this to my .yarnrc.yml file

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.1.1.cjs

Seems to have resolved it

@trohr
Copy link

trohr commented Jan 27, 2023

This issue seems to be solved for us after upgrading create-react-app to 5.0.1 (and yarn to 3.3.1).

We have previously used solution provided by Ilimos (#11793 (comment)). Now yarn start & yarn build works for us with that workaround removed from .yarnrc.yml.

@bharat407
Copy link

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

@trohr
Copy link

trohr commented Jun 5, 2023

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

Hi. How is that CRA is not maintained anymore? You are writing in CRA issues list :-D
Isn't this just some advertisement of the Vite project? :D

@bharat407
Copy link

bharat407 commented Jun 5, 2023 via email

@hock6191
Copy link

hock6191 commented Apr 2, 2024

NGATTFPVV

@Mezzle Mezzle closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions: up for grabs! dependencies Pull requests that update a dependency file issue: bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.