📘

【Next.js】@types/reactが認識されない場合の対応方法

2022/07/13に公開

概要

@types/react 18.0.2 をインストールしたが認識されない事象があったので対処方法をまとめる

https://github.com/vercel/next.js/issues/36085

It looks like you're trying to use TypeScript but do not have the required package(s) installed.

Please install @types/react by running:

        yarn add --dev @types/react

If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).

@types/reactをダウングレードする

issuesの通りだが18.0.2にバグがあるらしくダウングレードすることで正常化するとのこと

npm install --save-dev @types/react@18.0.1
GitHubで編集を提案

Discussion