admin管理员组文章数量:1193346
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?
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?
6 Answers
Reset to default 6Here 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 }]
]
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",
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
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.
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)
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"
},
本文标签:
版权声明:本文标题:javascript - Getting Cannot find module '@babelplugin-proposal-private-property-in-object' when running React Ap 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738467938a2088411.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
babel/preset-env
. Are you sure you need to be installing it separately at all? Might be a bug withcreate-react-app
if you're actually doing a fresh bootstrap – Mike K Commented May 26, 2023 at 16:47