Reputation: 301
I created a React App using npx create-react-app my_app
but when I am running the app using npm start
, I am getting the following error,
I tried installing the package '@babel/plugin-proposal-private-property-in-object' using npm install @babel/plugin-proposal-private-property-in-object
but still getting the same error. How to solve this?
Upvotes: 9
Views: 25627
Reputation: 116
for me the only thing helps was to install the @babel/plugin-proposal-private-property-in-object
package and then remove the node_modules folder with rm -rf node_modules --force
and then reinstall it
Upvotes: 3
Reputation: 31
Step 1: Add a babel.config.js file to the root of the project
Step2: 2: Run this code in the terminal
npm i @babel/plugin-transform-private-property-in-object
Step 3: Add the code below to the Babel.config file
plugins: [
...
require('@babel/plugin-proposal-private-property-in-object').default,
require('@babel/plugin-proposal-private-methods').default
];
Step 4: Add these lines of code to the package.json file
"devDependencies": {
"@babel/plugin-transform-private-property-in-object": "^7.23.3"
},
Upvotes: 0
Reputation:
I discovered that when you save this code in package.json
, an additional error will show up. However, if you remove it and save it again, both issues are resolved and the code compiles perfectly.
"devDependencies": {
"@babel/plugin-transform-private-property-in-object": "^7.23.3"
}
(If someone knows a permanent solution, please do reply to this)
Upvotes: 1
Reputation: 51
This error occurs when Babel plugin is missing or not installed. Add "@babel/plugin-proposal-private-property-in-object": "^7.21.0", to the list of dependencies in the package.json file like:
"dependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.0",
Upvotes: 5
Reputation: 21
After receiving a warning "One of your dependencies, babel-preset-react-app, is importing the package "@babel/plugin-proposal-private-property-in-object" without declaring it in its dependencies. This is currently working because the package "@babel/plugin-proposal-private-property-in-object" is already in your node_modules folder for unrelated reasons, but it may break at any time." I reinstalled @babel/plugin-proposal-private-property-in-object from the website https://www.npmjs.com/package/@babel/plugin-proposal-private-property-in-object.
Upvotes: 2
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 }]
]
Upvotes: 6