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
Thanks to all, eventually that's what solved my problem:
npm install --save-dev @babel/plugin-proposal-private-property-in-object --legacy-peer-deps
I tried to add
"@babel/plugin-proposal-private-property-in-object": "^7.21.11"
to devDependencies, and myCI=npm run build
was successfully completed.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.
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
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:
Here is a combination of babel packages that worked for me:
IMPORTANT STEP: Add
@babel/plugin-proposal-private-property-in-object
to .babelrc plugins as well. Something like this:See GitHub Issue:
https://github.com/babel/babel-plugin-proposal-private-property-in-object/issues/1
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