57

my issue is that I've tried to create a new react project and after a lot of issues with vulnerabilities I managed to solve some of them, one of the main instructions was adding this line:

"overrides": {
    "@svgr/webpack": "$@svgr/webpack"
  },

into my package.json file. Once I've done that I had to delete my node_modules folder and reuse npm install and now I am getting a babel error after typing npm start.

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 maintianed anymore. It is thus unlikely that this bug will
ever be fixed. Add "@babel/plugin-proposal-private-property-in-object" to
your devDependencies to work around this error. This will make this message
go away.

I tried to search for the solution over the internet and I found only one that tells me to add this plugin to my devDependencies which did not work, and I also found a solution that tells to type CI= npm run build which didn't work either.

This is what I'm encountering when typing npm list @babel/plugin-proposal-private-property-in-object :


npm ERR! code ELSPROBLEMS
npm ERR! invalid: @babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2 C:\Users\Omri-PC\Desktop\KeeperApp\node_modules\@babel\plugin-proposal-private-property-in-object
keeper-app-part-1-starting@1.0.0 C:\Users\Omri-PC\Desktop\KeeperApp
├── @babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2 invalid: "^x.x.x" from the root project
└─┬ @svgr/webpack@8.0.1 overridden
  └─┬ @babel/preset-env@7.22.5
    └── @babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2 deduped invalid: "^x.x.x" from the root project

And that's how my package.json file looks like if it somehow helps to figure:

{
  "name": "keeper-app-part-1-starting",
  "version": "1.0.0",
  "description": "",
  "keywords": [],
  "main": "src/index.js",
  "dependencies": {
    "react": "18.2.0",
    "react-dom": "18.2.0"
  },
  "devDependencies": {
    "@svgr/webpack": "^8.0.1",
    "react-scripts": "5.0.1",
    "typescript": "5.1.3"
  },
  "overrides": {
    "@svgr/webpack": "$@svgr/webpack"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

Hope that I gave you enough information in order to help me solve this issue, thanks a lot!

Omri Ben Lulu
  • 721
  • 1
  • 2
  • 7
  • ELSPROBLEMS mans that npm detects that the node_modules folder has an invalid layout. Could you try adding the devDependency, deleting node_modules and package-lock.json, and re-running npm install? – Nicolò Jun 09 '23 at 10:22

13 Answers13

77

Running the below command solved my issue

npm install --save-dev @babel/plugin-proposal-private-property-in-object

use --save-dev to install it under devDependencies

Kunal Tyagi
  • 2,341
  • 1
  • 15
  • 26
  • Running this command as supplied also fixed my repo. Annoyingly, I had seen numerous "just add it to the dev dependencies" comments with no instructions how to do that. Thanks. – rob Jul 04 '23 at 12:21
  • 2
    This fixed my netlify build failure, which treats warnings as errors and fails the build. – ArifMustafa Jul 08 '23 at 11:01
15

Thanks to all, eventually that's what solved my problem: npm install --save-dev @babel/plugin-proposal-private-property-in-object --legacy-peer-deps

Omri Ben Lulu
  • 721
  • 1
  • 2
  • 7
7

I also faced this issue today. I solved by adding the required lib from here after that "npm start" and "npm run build" are fine for me. Note: used version number ^7.21.11

dev_smh
  • 71
  • 3
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 09 '23 at 21:08
5

Here is a combination of babel packages that worked for me:

"devDependencies": {
    "@babel/core": "7.22.5",
    "@babel/eslint-parser": "7.22.5",
    "@babel/plugin-proposal-private-property-in-object": "7.21.11",
    "@babel/preset-env": "7.22.5",
}

IMPORTANT STEP: Add @babel/plugin-proposal-private-property-in-object to .babelrc plugins as well. Something like this:

"plugins": [
    ["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
]

See GitHub Issue: https://github.com/babel/babel-plugin-proposal-private-property-in-object/issues/1

Tunji Oyeniran
  • 3,948
  • 1
  • 18
  • 16
3

I tried to add "@babel/plugin-proposal-private-property-in-object": "^7.21.11" to devDependencies, and my CI=npm run build was successfully completed.

  • **Hint:** Add it into the `dependencies: { ... }` section of project's `package.json` file. – Matt Jun 26 '23 at 13:44
2

Also just started having this issue today. Added the recommended package to the devDependencies but also having no success.

Update: Updating my global yarn install (or maybe whatever your package manager of choice is) appears to fix the issue.

Follow Up: This fix worked for my development and host server but not my production node container.

Community
  • 1
  • 1
jps_dot_dev
  • 65
  • 1
  • 13
  • If you are using Yarn, you might try using `resolutions` (https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/) to force babel-preset-react-app to get the correct version of that dependency. – Nicolò Jun 09 '23 at 10:07
  • I ended up having to switch to pnpm to get production online again after a large outage. Unfortunately yarn has completely lost my faith after yesterday as did react-scripts which is being switched over to Vite. – jps_dot_dev Jun 10 '23 at 00:41
2

I was working on a hobby project earlier today and got the same warning. You just have to add the entry for "@babel/plugin-proposal-private-property-in-object" under the devDependencies object with the installed version in your project. You can find the installed version for your project in the following path:

node_modules/@babel/plugin-proposal-private-property-in-object/package.json

Once you have this version, just update the entry as mentioned above in the main package.json file of the project (the one that has the run and test commands and so on).

Here are the contents of the package.json file I modified to get rid of the warning message:

{
  "name": "clothes_shop",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "devDependencies": {
    "@babel/plugin-proposal-private-property-in-object": "^7.21.0-placeholder-for-preset-env.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
enigma6174
  • 340
  • 1
  • 7
  • 20
2

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.

Add @babel/plugin-proposal-private-property-in-object to your devDependencies to work around this error. This will make this message go away.

this command help you to solve this problem:

npm install --save-dev @babel/plugin-proposal-private-property-in-object --legacy-peer-deps
vsync
  • 118,978
  • 58
  • 307
  • 400
2

All you need to do to suppress the warning, is to open package.json and add

"@babel/plugin-proposal-private-property-in-object": "7.21.11", as described below. That would help you fix the issue.

"dependencies": {
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "@babel/plugin-proposal-private-property-in-object": "7.21.11",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },

or you can simply run this

npm install --save-dev @babel/plugin-proposal-private-property-in-object

Note: this would target devDependencies

Abdulkabir Ojulari
  • 1,407
  • 7
  • 14
1

if you prefer yarn, this is the equivalent command

yarn add @babel/plugin-proposal-private-property-in-object --dev
Java bee
  • 2,522
  • 1
  • 12
  • 25
1

Run this line :

npm install --save-dev @babel/plugin-proposal-private-property-in-object
toyota Supra
  • 3,181
  • 4
  • 15
  • 19
0

I got this message on my VS code:

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.

To sort this issue simply install what the warning is suggesting, I am using npm so just do:

npm i @babel/plugin-proposal-private-property-in-object -D

-D means that its only for local development

LBV
  • 1
  • 1
0

I realized I got this error because I am using Chakra UI, and using the private statement which is not readily available for older browsers.

I installed the package per the instructions here: https://www.npmjs.com/package/@babel/plugin-proposal-private-property-in-object

npm install --save-dev @babel/plugin-proposal-private-property-in-object

Finally, I had to add a Babel file

.babelrc

{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": ["@babel/plugin-proposal-private-property-in-object"]

}