Skip to content

Couldn't find a declaration file for module 'react' #9891

Closed
@JJ810

Description

@JJ810

Describe the bug

I created a typescript template create-react-app by running npx create-react-app --template typescript and tried to import
useEffect 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

  1. run npx create-react-app --template typescript
  2. open App.tsx and import useEffect and/or useState import React, { useEffect, useState } from 'react'
  3. save file and refresh

Actual behavior

I got error and couldn't run the project.

Screen Shot 2020-10-24 at 4 01 35 PM

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions