I am running a React project using npm. After hours of research and experimenting, everywhere says I have to add the following code to my ".babelrc" file, which I do not have in my directory and cannot create:
{
"plugins": [
["@babel/plugin-proposal-class-properties", { "loose": true }]
]
}
But this leads to the following error when I run the code:
ERROR in ./src/components/NavBar/Menu.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /Users/ymoondhra/Desktop/yt-web/src/components/NavBar/Menu.js:
Support for the experimental syntax 'classProperties' isn't currently enabled
(20:10):
18 | }
19 |
> 20 | fast = () => {
| ^
21 | this.speed = 100;
22 | }
23 |
Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins'
section of your Babel config to enable transformation.