1

I'm using mobx in a react app and I keep getting this error: Support for the experimental syntax 'decorators-legacy' isn't currently enabled in the title even though I tried this solution, deleted node_modules folder and npm install-ed, here are my files:

// .babelrc

{
  "presets": ["@babel/preset-env"],
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy": true }],
    ["@babel/plugin-proposal-class-properties", { "loose": true }]
  ]
}

// package.json

{
  "name": "app-spotify",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "axios": "^0.19.2",
    "mobx": "^5.15.4",
    "mobx-react": "^6.1.8",
    "react": "^16.13.0",
    "react-dom": "^16.13.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@babel/core": "^7.1.0",
    "@babel/plugin-proposal-class-properties": "^7.1.0",
    "@babel/plugin-proposal-decorators": "^7.1.0",
    "@babel/preset-env": "^7.1.0"
  }
}
E_net4
  • 27,810
  • 13
  • 101
  • 139
Cedric Hadjian
  • 849
  • 12
  • 25
  • @HereticMonkey Of course, I also tried their `decorator` utility function, which is `"presets": ["mobx"]` you mean, right? It also didn't work. Something tells me my app isn't reading the .babelrc file, I just created the file and that was it, should I do anything specific? – Cedric Hadjian Mar 26 '20 at 17:02
  • I mean [read all of the answers to the duplicate question. This one I'm linking to notes that renaming from `.babelrc` to `babel.config.json` worked for them](https://stackoverflow.com/a/59935289/215552). Did you try that answer? – Heretic Monkey Mar 26 '20 at 17:05
  • @HereticMonkey Hey just so I update you, I didn't know I had to eject the react app for it to work, I had no idea. It worked when I ejected, thank you! – Cedric Hadjian Mar 28 '20 at 13:29
  • Does this answer your question? [Syntax error - Support for the experimental syntax 'decorators-legacy' isn't currently enabled](https://stackoverflow.com/questions/52262084/syntax-error-support-for-the-experimental-syntax-decorators-legacy-isnt-cur) – Heretic Monkey Mar 28 '20 at 21:46
  • @HereticMonkey not really, I remember trying this as well. The only thing that worked for me is when I set up babel in package.json and ejected the react app. – Cedric Hadjian Mar 30 '20 at 20:38

0 Answers0