babel-preset-react-app uses the "@babel/plugin-proposal-private-property-in-object" package without explicitly listing it as a dependency
P粉165823783
P粉165823783 2023-10-18 20:38:28
0
1
1109

My problem is that I tried to create a new react project and after having a lot of bug issues I managed to solve some of them, one of the main instructions was to add this line:

"overrides": { "@svgr/webpack": "$@svgr/webpack" },

Go into my package.json file. Once done I had to delete my node_modules folder and reusenpm installand now I get babel error after typingnpm 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 searching the internet for solutions but I found only one that told me to add this plugin to my devDependency but that didn't work and I also found one that told me to enterCI= npm run builddoesn't work either.

This is what I encountered when typingnpm 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 keeper-app-part-1-starting@1.0.0 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/webpack@8.0.1 overridden └─┬ @babel/preset-env@7.22.5 └── @babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2 deduped invalid: "^x.x.x" from the root project

This is what my package.json file looks like (if it helps understanding somehow):

{ "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 I gave you enough information to help me solve this problem, thank you very much!

P粉165823783
P粉165823783

reply all (1)
P粉436688931

Running the following command solved my problem

npm install --save-dev @babel/plugin-proposal-private-property-in-object

Use --save-dev to install it under devDependencies

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!