![](/img/trans.png)
[英]Lerna, yarn, and Typescript: Cannot find module or its corresponding type declarations
[英]Vue js 3 with TypeScript Cannot find module 'xxxxxx' or its corresponding type declarations
我使用 vue js 2 制作了一個分頁插件。在另一個項目中使用 Vue 3 和 TypeScript 時出現錯誤。 錯誤消息是“找不到模塊‘l-分頁’或其相應的類型聲明”。 當我下載了幾個不同的項目時,它們運行良好。 我正在創建的插件中是否存在問題,或者是否有解決此錯誤的不同方法(“找不到模塊‘l-分頁’或其相應的類型聲明”)?
Shims-vue.d.ts
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
配置文件
{
"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"
]
}
添加到 tsconfig.json:
"types": ["node"]
並安裝@types/node:
npm install --save-dev @types/node
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.