简体   繁体   中英

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. The error message is 'Cannot find module 'l-pagination' or its corresponding type declarations'. 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')?

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:

"types": ["node"]

and install @types/node:

npm install --save-dev @types/node

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM