I have a react/typescript app made with create-react-app
When I try to yarn start
in my computer i get the following error:
Failed to compile.
undefined
TypeScript error in undefined(undefined,undefined):
Cannot find type definition file for 'async'. TS2688
I don't understand why is this error happening. Why would async
need a type definition? And why is it not finding it?
I already tried removing node_modules
and yarn.lock
and doing `yarn install``
I also tried removing the whole folder and cloning my repo again (and installing everything again).
Curiously, this works perfectly fine in my laptop when I clone the repo:
https://github.com/grochadc/filex-workshops-registration
package.json
:
{
"name": "typescript-react-testing",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "10.0.0",
"@testing-library/user-event": "^12.1.5",
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"@types/yup": "^0.29.7",
"bootstrap": "^4.5.2",
"dotenv": "^8.2.0",
"firebase": "^7.21.0",
"formik": "^2.1.5",
"json-server": "^0.16.1",
"mutation-observer": "^1.0.3",
"react": "^16.13.1",
"react-bootstrap": "^1.3.0",
"react-dom": "^16.13.1",
"react-responsive": "^8.1.0",
"react-scripts": "3.4.3",
"styled-components": "^5.2.0",
"typescript": "4.0.3",
"yup": "^0.29.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"json-server": "json-server --watch db.json --port 5000"
},
"proxy": "http://localhost:5000",
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@testing-library/dom": "^7.24.2",
"jest-fetch-mock": "^3.0.3"
}
}
tsconfig.json
{
"compilerOptions": {
"noImplicitAny": false,
"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"
},
"include": ["src"]
}
I edited the file that was giving me the async problem (I removed async) and I keep getting the same error.
Atom Linter gives me an error at the start of tsconfig.json
like this:
Cannot find type definition file for 'async' .
Cannot find type definition file for 'graphql' .
Cannot find type definition file for 'isomorphic-fetch' .
Im stumped because I didn't add graphql
as a dependency (it is certainly not in package.json
).
这可能与您使用的节点版本有关,最低版本应为 nvm 10.18,因此请确保您具有正确的依赖项。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.