-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Couldn't find a declaration file for module 'react' #9891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
I had the same issue. Adding and restarting the server fixed it. |
I had this issue today - i think something is going on with running
I can see I have but after running
The types aren't there anymore Investigating - I think this is because I have yarn installed globally - and CRA is therefore using yarn to install the deps - after running the Running
initially - to force CRA to use npm seemed to fix this issue... is this just a weird conflict due to me using |
Quick fix for an already existing project:
|
Describe the bug
I created a typescript template create-react-app by running
npx create-react-app --template typescript
and 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 typescript
import 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: