जब मैं Django परियोजना के भीतर प्रतिक्रिया स्थापित कर रहा था तो मुझे यह त्रुटि आई
मॉड्यूल बिल्ड में ModuleBuildError विफल (से ./node_modules/babel-loader/lib/index.js): SyntaxError: C: \ Users \ 1Sun / Cebula3 \ cebula_react \ आस्तियों \ js \ index.js: प्रयोगात्मक वाक्यविन्यास वर्ग के लिए समर्थन। वर्तमान में सक्षम नहीं है (17: 9):
15 |
16 | class BodyPartWrapper extends Component {
> 17 | state = {
| ^
18 |
19 | }
20 |
Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the
'plugins' section of your Babel config to enable transformation.
इसलिए, मैंने @ babel / plugin- प्रस्ताव-वर्ग-गुण स्थापित किए और इसे babelrc में रखा
package.json
{
"name": "cebula_react",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --config ./webpack.config.js --mode development",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --config prod.config.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"babel": {
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"react-hot-loader": "^4.3.6",
"webpack": "^4.17.2",
"webpack-bundle-tracker": "^0.3.0",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.8"
},
"dependencies": {
"react": "^16.5.0",
"react-dom": "^16.5.0"
}
}
babelrc
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
हालाँकि त्रुटि अभी भी मौजूद है, समस्या क्या है ??
npx babel-upgrade --write --install
@babel/plugin-proposal-class-properties
और दोनों की आवश्यकता नहीं होनी चाहिएbabel-plugin-transform-class-properties
। आप स्थापित करने के बाद पुनर्निर्माण कर रहे हैं, हाँ?