mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.74k stars 32.24k forks source link

Cannot find type definition file for 'react-scripts'.ts(2688) in react-app.env.ts #34752

Closed Fil-good closed 2 years ago

Fil-good commented 2 years ago

After copying the code, and some updates of npm, etc. I cannot remove this error code (see subject line). Anyone has an idea how to fix this?

package.json

{
  "name": "tsc-week5",
  "version": "1.0.0",
  "description": "",
  "main": "index.html",
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "author": "mui",
  "license": "MIT",
  "dependencies": {
    "@emotion/react": "^11.10.4",
    "@emotion/styled": "^11.10.4",
    "@fontsource/roboto": "^4.5.8",
    "@mui/icons-material": "^5.10.9",
    "@mui/material": "^5.10.9",
    "@mui/styled-engine-sc": "^5.10.6",
    "@types/jest": "^29.1.2",
    "@types/react": "^18.0.21",
    "@types/react-dom": "^18.0.6",
    "styled-components": "^5.3.6",
    "typescript": "^4.8.4"
  },
  "devDependencies": {
    "@types/node": "^18.8.5",
    "webpack": "^5.74.0"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react",
    "types": [
      "node"
    ],
    "typeRoots": [
      "node_modules/@types",
      "src/typings"
    ]
  },
  "include": [
    "src"
  ]
}
michaldudak commented 2 years ago

It doesn't look like this bug report has enough info for one of us to reproduce it.

Please provide a CodeSandbox (https://mui.com/r/issue-template), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem.

Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

Fil-good commented 2 years ago

so, an hour later, everything is working! in the end there was only 1 issue, and by changing, in the tsconfig.json: "jsx": "react" to "jsx: "react-jsx" everything was ok. This was the only difference in the tsconfig file from the example of the forked repo.

my solution to all previous difficulties, was to use 'npm update' (I also changed my lock file with shrinkwrap, but not sure if this was the solution). Also, it helped maybe to restart the IDE.
PS. also I did 'npm install react-scripts@latest'