Joseph D Joseph D - 22 days ago 6
React JSX Question

error TS2307: Cannot find module 'react'

I am trying to create a component with typescript but I am getting the following error in the terminal yet I already installed react and react-dom using npm.

ERROR in ./main.tsx error TS2307: Cannot find module 'react'.

Answer

Oooh I see.. Try this

You also need to install the typescript definition files for react. You can do that using npm as shown below

npm install @types/react