Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Next.js is not recognizing '@types/react'

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 npm install --save-dev @types/react and got no error messages (just a bunch of warnings but I don’t think they are the problem).

How can I solve this and run the project?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Seems like there is a bug in the current @types/react version (specifically v18.0.2), you can downgrade to 18.0.1 with npm install --save-dev @types/react@18.0.1

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading