close

[Solved] Cannot use JSX unless the ‘–jsx’ flag is provided

Hello Guys. Today I am trying to change my .tsx file But then I am facing the following error: Cannot use JSX unless the ‘–jsx’ flag is provided in ReactJs. We are going to Learn about All Possible Solutions So Lets Get Start with This Article.

How Cannot use JSX unless the ‘–jsx’ flag is provided Error Occurs ?

I am trying to change my .tsx file But then I am facing the following error.

Cannot use JSX unless the '--jsx' flag is provided

How To Solve Cannot use JSX unless the ‘–jsx’ flag is provided Error ?

  1. How To Solve Cannot use JSX unless the '–jsx' flag is provided Error?

    To Solve Cannot use JSX unless the '–jsx' flag is provided Error If You are using VS code then configure this setting to solve this error. First of all type CTRL + Shift + P For Windows  + Shift + P For Mac Users. Then Type : TypeScript: Select a TypeScript Version and Select It. Then, Look at the Bottom Of Your VS code You can Find the workspace Version and Choose “Use workspace Version”. Now, Your error should be solved.

  2. Cannot use JSX unless the '–jsx' flag is provided

    To Solve Cannot use JSX unless the '–jsx' flag is provided Error Here Problem is Some times tsconfig.json takes some time to changes and That's why you are facing this error all You need to do is Just restart your IDE and Now, Your error might be gone.

Solution 1: Restart IDE

Here Problem is Some times tsconfig.json takes some time to changes and That’s why you are facing this error all You need to do is Just restart your IDE and Now, Your error might be gone.

Solution 2: For VS Code

If You are using VS code then configure this setting to solve this error.

  1. First of all type CTRL + Shift + P For Windows  + Shift + P For Mac Users.
  2. Then Type : TypeScript: Select a TypeScript Version and Select It.
  3. Then, Look at the Bottom Of Your VS code You can Find workspace Version and Choose “Use workspace Version”.
  4. Now, Your error should be solved.

Hope Now, Your error should be solved.

Solution 3: add this line in tsconfig.json

You need to add this line and also in include was set only to /src, Change to: ./src/*/.ts in Your tsconfig.json file.

  "compilerOptions": {
    "jsx": "react"
  },
  "include": [
    "./src/**/*.ts"
  ]

Now, Your error must be solved. Thank You.

Summary

It’s all About this error. Hope We solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Leave a Comment