pro-mern-stack-2 icon indicating copy to clipboard operation
pro-mern-stack-2 copied to clipboard

Support for the experimental syntax 'jsx' isn't currently enabled (with solution)

Open Darter90 opened this issue 5 years ago • 0 comments

I ended up the second book chapter; when I tried to launch npm run watch, Babel throw this error:

Support for the experimental syntax 'jsx' isn't currently enabled

To solve this, you have to:

  1. add this dependency to your package.json: "@babel/preset-env": "^7.12.13" <--- same version of @babel/preset-react

  2. Launch npm install. Those are my dependencies at this point:

     "@babel/cli": "^7.13.10",
     "@babel/core": "^7.13.10",
     "@babel/preset-env": "^7.12.13",
     "@babel/preset-react": "^7.12.13",
     "express": "^4.17.1",
     "node": "14.16.0",
     "nodemon": "2.0.7"
    
  3. Subsequently, you have to change Babel's configuration settings. You can do it with an external file

  4. At the root folder of your project (where package.json is located), create a new file named "babel.config.js" and add those lines:

     module.exports = {
         presets:[
             "@babel/preset-env",
             "@babel/preset-react"
         ]
     }
    

When I tried to launch again npm run watch, the issue was gone.

Original solution: https://stackoverflow.com/questions/62703393/support-for-the-experimental-jsx-isnt-currently-enabled

Darter90 avatar Mar 14 '21 20:03 Darter90