'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'.
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Edwin Kato |