Reputation: 1901
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 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 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.
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
[email protected] 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/[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"
]
}
Upvotes: 155
Views: 274575
Reputation: 79
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"]
}
Upvotes: 2
Reputation: 1847
TL;DR: Old answers suggest installing a package (plugin-proposal...), but it was renamed, and the most updated solution is to use the [babel/plugin-transform
...] instead by updating your package.JSON file.
If you have this (@babel/plugin-proposal-...) in your package.JSON:
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.16.7", // PROPOSAL
...
}
Switch to this (@babel/plugin-transform-...) - Or install if you don't have any
"devDependencies": {
"@babel/plugin-transform-private-property-in-object": "^7.23.4", // TRANSFORM
...
}
More info can be found here at Babel/plugin-transform documentation:
Upvotes: 11
Reputation: 39
For me, all I needed to do was update typescript to the latest version. My project uses both typescript and javascript. This fixed it for me:
npm install typescript@latest
The latest version of typescript at the time of this writing is 5.5.4.
Upvotes: 2
Reputation: 109
I found that you also need to update the things that are using the old dep.
For example in my case @babel/preset-env was using this deps, so by doing:
npm install --save-dev @babel/preset-env
I solved the issue
Upvotes: -1
Reputation: 11
In our project we try to keep using the react-scripts package with as few changes as possible, therefore I have recently encountered this warning when running our tests.
If I do as the warning suggests, run npm install --save-dev @babel/plugin-proposal-private-property-in-object
, I end up with a line under my devDependencies that point to the latest version.
The warning will now be gone from the console when running tests. However, I now get a deprecation warning when installing.
My work around for this is to alias the package. I change the devDependency in package.json to the following:
"@babel/plugin-proposal-private-property-in-object": "npm:@babel/plugin-transform-private-property-in-object@^7.24.1"
Then when I run npm install
the warnings are gone.
Hope this helps.
Upvotes: -1
Reputation: 4177
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
The package @babel/plugin-proposal-private-property-in-object
is deprecated.
Use npm install --save-dev @babel/plugin-transform-private-property-in-object
instead.
Reference the package in your .eslintrc
, e.g.
{
"extends": ["@babel/plugin-transform-private-property-in-object", "next/core-web-vitals"]
}
Upvotes: 245
Reputation: 1
I tried all of the above but nothing worked for me. It turned out that react didn't like that the parent folder for my project had a # in it. C:\C#\myreactapp It didn't like the naming of the C# folder. I changed the location to C:\MyProjects\myreactapp and the issue was resolved.
Upvotes: -1
Reputation: 1
just add
"@babel/plugin-proposal-private-property-in-object": "^7.16.7"
at dependencies
in package.json
I hope your warning will go.
My Code
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@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",
"@babel/plugin-proposal-private-property-in-object": "^7.16.7"
},
Upvotes: -1
Reputation: 1
to solve this issue just do this :
package-lock.json
(but don't delete package.json
)npm i
This will delete all the node modules and will reinstall all from fresh. just be careful when deleting anything.
This solved my issue with babel
Upvotes: -1
Reputation: 41
I faced the same issue and using this solves my issue. @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.
Upvotes: 2
Reputation: 24
I solved this problem simply by updating all the dependencies. Apparently, they solved this issue in latest updates.
You can use npm-ckeck-updates package for this matter.
Here is the process:
npm i npm-check-updates
ncu -u
npm install
That's it. Good luck.
Upvotes: -1
Reputation: 21
I simply created a ".babelrc.sjon" file on the root of my application and wrote into it:
"presets": ["@babel/preset-env", "@babel/preset-react"]
Upvotes: 1
Reputation: 1
I got this message on my Visual Studio 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.
Upvotes: -1
Reputation: 3107
If you prefer yarn
, this is the equivalent command:
yarn add @babel/plugin-proposal-private-property-in-object --dev
Upvotes: 7
Reputation: 541
This worked for me.
yarn add --dev @babel/plugin-proposal-private-property-in-object
use --dev to install it under devDependencies
Pls, remember use engine node version >= 16.0.0
Upvotes: 0
Reputation: 71
By adding this line with the specified version, you are telling npm to install version 7.21.11 of the
@babel/plugin-proposal-private-property-in-object
package as a dependency. This can help fix any issues related to the plugin or suppress related warnings.
Node: while installing/building the app one warning came up as:
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.
I recommend to use:
"@babel/plugin-transform-private-property-in-object": "^7.21.11"
my build was success
After making this change, you should run npm install to ensure that the specified version of the package is installed in your project.
Please note that specifying a fixed version like this can help maintain consistency in your project but may require periodic updates to stay up-to-date with the latest package improvements and security updates.
Upvotes: 3
Reputation: 364
TL;DR: If you're using a monorepo you must add the dev dependency to both the React app in question and the root package.json
, not just to the React app.
More fulsome answer: if you have a monorepo (I'm using NPM Workspaces but this may apply to other monorepos too), where one of your apps is the React app in question, similar to:
├── apps
│ ├── my-express-api
│ │ └── package.json
│ └── my-cra-app
│ └── package.json
├── package.json
└── package-lock.json
You'll need to add the @babel/plugin-proposal-private-property-in-object
dev dependency to both your React app and the monorepo's root package.json
, similar to:
// add to app
npm i @babel/plugin-proposal-private-property-in-object --save-dev -w my-cra-app
// ... and to root
npm i @babel/plugin-proposal-private-property-in-object --save-dev
Upvotes: -1
Reputation: 21
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
Upvotes: 2
Reputation: 1901
Thanks to all, eventually that's what solved my problem:
npm install --save-dev @babel/plugin-proposal-private-property-in-object --legacy-peer-deps
Upvotes: 35
Reputation: 4394
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
Upvotes: 5
Reputation: 360
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"
]
}
}
Upvotes: 4
Reputation: 125
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.
Upvotes: 2
Reputation: 81
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
Upvotes: 8
Reputation: 71
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.
Upvotes: 7