Home > Mobile >  Next.js is not recognizing '@types/react'
Next.js is not recognizing '@types/react'

Time:04-12

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?

CodePudding user response:

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/[email protected]

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

  • Related