Couldn't find a declaration file for module 'react' #9891
Comments
|
This is already discussed in #9882 |
I don't think that issue is discussing the same problem. This appears to be in reference to the type declaration files, not React itself. I have the same error on a fresh CRA Typescript project today and the issue you reference already had a fix merged. I was able to resolve this by removing node_modules and reinstalling. |
|
@BrandonGardner2, you should run
to fix this issue. But I couldn't find where to add this package in this repo. |
yea, it looked as if the @types/react failed to install in the initial creation. The dependency is created in the package.json. I just wiped node_modules in case anything else was missed. luckily that is all that was needed haha. |
This worked for me, and i used the create-react-app tsx starter template. |
|
Why does this work with everyone, iand not me. All without any success. Any suggestion would be greatly appreciated |
|
I ran Why is this happening for clean runs? |
|
I'm getting this issue as well, after installing the typescript template, and then installing reactstrap. Was able to solve it by deleting node_modules and running npm install again |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Describe the bug
I created a typescript template create-react-app by running
npx create-react-app --template typescriptand tried to importuseEffect and useState. After I import and save file, I got an error: Could not find a declaration file for module 'react'
Did you try recovering your dependencies?
6.14.6
Environment
current version of create-react-app: 4.0.0
running from /Users/healer/.npm/_npx/25783/lib/node_modules/create-react-app
System:
OS: macOS High Sierra 10.13.6
CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
Binaries:
Node: 10.22.1 - ~/.nvm/versions/node/v10.22.1/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.6 - ~/.nvm/versions/node/v10.22.1/bin/npm
Browsers:
Chrome: 86.0.4240.111
Edge: 86.0.622.51
Firefox: 81.0.2
Safari: 13.0.5
npmPackages:
react: ^17.0.1 => 17.0.1
react-dom: ^17.0.1 => 17.0.1
react-scripts: 4.0.0 => 4.0.0
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
npx create-react-app --template typescriptimport React, { useEffect, useState } from 'react'Actual behavior
I got error and couldn't run the project.
The text was updated successfully, but these errors were encountered: