简体   繁体   English

带有 TypeScript 的 Vue js 3 找不到模块“xxxxxx”或其相应的类型声明

[英]Vue js 3 with TypeScript Cannot find module 'xxxxxx' or its corresponding type declarations

I made a pagination plugin with vue js 2. I get an error when using Vue 3 with TypeScript in another project.我使用 vue js 2 制作了一个分页插件。在另一个项目中使用 Vue 3 和 TypeScript 时出现错误。 The error message is 'Cannot find module 'l-pagination' or its corresponding type declarations'.错误消息是“找不到模块‘l-分页’或其相应的类型声明”。 When I downloaded a few different projects, they worked fine.当我下载了几个不同的项目时,它们运行良好。 Is the problem in the plugin I'm creating or is there a different method for solving this error ('Cannot find module 'l-pagination' or its corresponding type declarations')?我正在创建的插件中是否存在问题,或者是否有解决此错误的不同方法(“找不到模块‘l-分页’或其相应的类型声明”)?

Shims-vue.d.ts Shims-vue.d.ts

declare module '*.vue' {
  import type { DefineComponent } from 'vue'
  const component: DefineComponent<{}, {}, any>
  export default component
}

tsconfig.json配置文件

{
  "compilerOptions": {
    "noImplicitAny": false,
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "webpack-env"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}

add to tsconfig.json:添加到 tsconfig.json:

"types": ["node"]

and install @types/node:并安装@types/node:

npm install --save-dev @types/node

暂无
暂无

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

相关问题 Lerna、yarn 和 Typescript:找不到模块或其对应的类型声明 - Lerna, yarn, and Typescript: Cannot find module or its corresponding type declarations 带有 Typescript 的 MaterialUI:找不到模块“csstype”或其相应的类型声明 - MaterialUI with Typescript: Cannot find module 'csstype' or its corresponding type declarations 打字稿 - 找不到模块......或其相应的类型声明 - Typescript - Cannot find module ... or its corresponding type declarations 业力,Webpack &amp; Typescript:TS2307:找不到模块“log4js”或其相应的类型声明 - Karma, Webpack & Typescript: TS2307: Cannot find module 'log4js' or its corresponding type declarations 错误:找不到模块“jsonwebtoken”或其对应的类型声明 NODE.JS 和 TYPESCRIPT - ERROR: Cannot find module 'jsonwebtoken' or its corresponding type declarations with NODE.JS and TYPESCRIPT 找不到模块“crypto-js”或其相应的类型声明 - Cannot find module 'crypto-js' 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 TS2307:找不到模块“./App.vue”或其相应的类型声明 - TS2307: Cannot find module './App.vue' or its corresponding type declarations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM