Cannot find module 'react'
You are planning to use react inside typescript. Try this
npm install --save react react-dom @types/react @types/react-dom
I am using Gatsby and React was in my package.json with the following:
"react": "^16.7.0",
"react-dom": "^16.7.0",
It was previously working when I ran gatsby develop
. However, when I installed a couple of plugins (npm install --save less gatsby-plugin-less
), the "Error: Cannot find module 'react'" started popping up whenever whenever I did gatsby develop
.
Weirdly, I just did npm install
on the package.json folder and it fixed the issue.
Do npm install react
in your local directory.
It worked for me.
Your package.json doesn't have React in it. It's pretty hard for your project to use a package you haven't installed.
Just add: "react": "^15.3.1"
to your package.json and do a new npm install, and you should be fine.