LoginSignup
10

More than 3 years have passed since last update.

Reactアプリ作成時にエラー"'--jsx' フラグが指定されていないと、JSX を使用できません。"が発生する場合の対処

Posted at

現在

npx create-react-app hello-world --template typescript

上記コマンドで作成したプロジェクトをVSCode等で開くと、
各種tsxファイルにおいて

'--jsx' フラグが指定されていないと、JSX を使用できません。

上記エラーが発生する場合があります。
これは使用しているTypescriptのバージョンが古いことに起因するものです。

解決方法

ワークスペースのTypescriptを使用しましょう。
以下VSCodeの例

①VSCode右下のTypescriptのバージョンが表示されている箇所をクリック
image.png

②Typescriptのバージョンを選択
image.png

③ワークスペースのバージョンを使用
image.png

④VSCode再起動

以上でエラーは出なくなっているはずです。
お困りの方の手助けになれば幸いです。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10