Masalah saya ialah saya cuba mencipta projek reaksi baharu dan selepas menghadapi banyak masalah pepijat, saya berjaya menyelesaikan beberapa daripadanya, salah satu arahan utama ialah menambah baris ini:
"overrides": { "@svgr/webpack": "$@svgr/webpack" },
Pergi ke fail package.json saya.
Setelah selesai saya terpaksa memadamkan folder node_modules saya dan menggunakan semula npm install
,现在输入 npm start
Saya mendapat ralat babel.
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.
Saya cuba mencari penyelesaian di internet tetapi saya temui hanya satu yang memberitahu saya untuk menambah pemalam ini pada devDependency saya tetapi itu tidak berfungsi dan saya juga menemui penyelesaian yang menyuruh saya memasukkan CI= npm run build
yang juga tidak berfungsi .
Ini yang saya temui semasa menaip 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 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
Beginilah rupa fail package.json saya (jika ia membantu memahami entah bagaimana):
{ "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" ] }
Semoga saya memberi anda maklumat yang mencukupi untuk membantu saya menyelesaikan masalah ini, terima kasih banyak!
Menjalankan arahan berikut menyelesaikan masalah saya
npm install --save-dev @babel/plugin-proposal-private-property-in-object
Gunakan --save-dev untuk memasangnya di bawah devDependencies