[Solved] Next.js is not recognizing '@types/react'

Next JS Mohit Mozumder

Problem:

When I try to run my Next.js app with npm run dev I get an error message saying that I don't have the required packages to run Next with Typescript:

Please install @types/react by running:

npm install --save-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)

However, the module '@types/react' is installed. I tried running and got no error messages.


Solution:

Downgrade @types/react version to 18.0.1 with

npm install --save-dev @types/react@18.0.1

Thank you for reading the article. If you face any further problem feel free to ask us.