skip to Main Content

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:UsersOmri-PCDesktopKeeperAppnode_modules@babelplugin-proposal-private-property-in-object
[email protected] C:UsersOmri-PCDesktopKeeperApp
├── @babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2 invalid: "^x.x.x" from the root project
└─┬ @svgr/[email protected] overridden
  └─┬ @babel/[email protected]
    └── @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!

7

Answers


  1. Chosen as BEST ANSWER

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


  2. 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.

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
  4. 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

    Login or Signup to reply.
  5. 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"
        ]
      }
    }
    
    Login or Signup to reply.
  6. 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

    Login or Signup to reply.
  7. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search