Joseph D Joseph D - 1 year ago 174
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 Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download