简体   繁体   English

带有 Typescript 的 MaterialUI:找不到模块“csstype”或其相应的类型声明

[英]MaterialUI with Typescript: Cannot find module 'csstype' or its corresponding type declarations

I'm setting up a new vite project, and I can't figure out why, when I run tsc , that I get 784 errors related to MUI not being able to find the csstype module.我正在设置一个新的 vite 项目,但我不明白为什么在运行tsc时会出现与 MUI 无法找到csstype模块相关的 784 错误。 Example:例子:

 node_modules/@mui/styled-engine/index.d.ts:1:22 - error TS2307: Cannot find module 'csstype' or its corresponding type declarations.

I have these versions of MUI and TS:我有这些版本的 MUI 和 TS:

"@emotion/react": "^11.8.1",
"@emotion/styled": "^11.8.1",
"@mui/icons-material": "^5.4.4",
"@mui/material": "^5.4.4",
"typescript": "^4.5.5",

And this is my tsconfig:这是我的 tsconfig:

{
  "compilerOptions": {
    "target": "ESNext",
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react",

    "types": ["vite/client"],
    "baseUrl": "./src",
    "allowJs": false,
    "skipLibCheck": false,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,

    "paths": {
      "~/*": ["*"]
    },

    "removeComments": true,
    "noEmitOnError": true,
    "noImplicitAny": false,
    "strictNullChecks": false,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "forceConsistentCasingInFileNames": true,
    "noErrorTruncation": true,

    /* Experimental Options */
    "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */
  },
  "include": ["./src"],
  "exclude": ["node_modules"]
}

Similar issues I could read about are all about not having "moduleResolution": "Node" in their tsconfig, but I have had that all the time.我能读到的类似问题都是关于在他们的 tsconfig 中没有"moduleResolution": "Node" ,但我一直都有。

I had the same error message.我有同样的错误信息。 Installing csstype removed the error you have but did result in new errors personally.安装 csstype 删除了您遇到的错误,但确实导致了新的个人错误。

npm i csstype

Never figured out what was wrong, but something in the package-lock file might have become corrupted somehow.从来没有弄清楚哪里出了问题,但包锁定文件中的某些内容可能已以某种方式损坏。

Since it was a new project I was starting up, I just removed package-lock.json and the node_modules folder, and I cleanly reinstalled the newest stable versions of everything.由于这是我启动的一个新项目,我只是删除了 package-lock.json 和 node_modules 文件夹,然后干净利落地重新安装了所有的最新稳定版本。 The issues disappeared after that.之后问题就消失了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 打字稿 - 找不到模块......或其相应的类型声明 - Typescript - Cannot find module ... or its corresponding type declarations Lerna、yarn 和 Typescript:找不到模块或其对应的类型声明 - Lerna, yarn, and Typescript: Cannot find module or its corresponding type declarations 找不到模块“。” 或其相应的类型声明 - Cannot find module '.' or its corresponding type declarations VueJS/Typescript 错误:找不到模块“我的模块”或其相应的类型声明 - VueJS/Typescript error: Cannot find module 'my-module' or its corresponding type declarations 找不到模块“module.css”或其相应的类型声明 - Cannot find module 'module.css' or its corresponding type declarations “找不到模块'./style'或其相应的类型声明”错误,typescript linter - “Cannot find module './style' or its corresponding type declarations” error, typescript linter Typescript 找不到模块 `./app` 或其对应的类型声明 ts(2307) - Typescript cannot find module `./app` or its corresponding type declarations ts(2307) 类型错误:找不到模块“...”或其相应的类型声明 - Type error: cannot find module '...' or its corresponding type declarations VueJS/Typescript - 找不到模块“./components/Navigation”或其相应的类型声明 - VueJS/Typescript - Cannot find module './components/Navigation' or its corresponding type declarations 带有 TypeScript 的 Vue js 3 找不到模块“xxxxxx”或其相应的类型声明 - Vue js 3 with TypeScript Cannot find module 'xxxxxx' or its corresponding type declarations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM