close

[Solved] Syntax error: Support for the experimental syntax decorators-legacy isn’t currently enabled

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Syntax error: Support for the experimental syntax decorators-legacy isn’t currently enabled in javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How To Solve Syntax error: Support for the experimental syntax decorators-legacy isn’t currently enabled Error ?

  1. How To Solve Syntax error: Support for the experimental syntax decorators-legacy isn't currently enabled Error?

    To Solve Syntax error: Support for the experimental syntax decorators-legacy isn't currently enabled Error Just Solved this issue by running npm install –save-dev @babel/plugin-proposal-decorators and adding [“@babel/plugin-proposal-decorators”, { “legacy”: true }] to the plugins section in my .babelrc.

  2. Syntax error: Support for the experimental syntax decorators-legacy isn't currently enabled

    To Solve Syntax error: Support for the experimental syntax decorators-legacy isn't currently enabled Error Just Solved this issue by running npm install –save-dev @babel/plugin-proposal-decorators and adding [“@babel/plugin-proposal-decorators”, { “legacy”: true }] to the plugins section in my .babelrc.

Solution 1

Just Solved this issue by running npm install --save-dev @babel/plugin-proposal-decorators and adding ["@babel/plugin-proposal-decorators", { "legacy": true }] to the plugins section in my .babelrc.

The plugins section of .babelrc, for me, now looks like this:

"plugins": [
  ["@babel/plugin-proposal-decorators", { "legacy": true }]
]

Solution 2

First, execute the command:

npm install customize-cra react-app-rewired @babel/plugin-proposal-decorators --save

Create a new file config-overrides.js at project root and then execute the following:

const { override, addDecoratorsLegacy } = require('customize-cra');
module.exports = override(
 addDecoratorsLegacy()
 );

Also, edit your package.jsonfile :

"scripts": {
 "start": "react-app-rewired start",
 "build": "react-app-rewired build",
 "test": "react-app-rewired test",
 "eject": "react-app-rewired eject"
  },

then restart.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment