Cannot find module ‘xxx‘ or its corresponding type declarations.Vetur(2307)

问题描述:Cannot find module ‘‘store/index’ or its corresponding type declarations.Vetur(2307)

原因分析:以当前项目的上级目录为根目录, Vetur 不知道当前哪一层文件夹才是真正的根目录。

(1)在 tsconfig.json 中配置 baseUrl 和 paths

{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@": ["src/*"],
      "store/*": ["src/store/*"]
    }
  }
}

(2)通过vscode将文件夹加入到工作区时,必须单独加载,而且放在第一个
在这里插入图片描述

  • 6
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据引用\[1\]中的配置,你可以在tsconfig.json文件中设置baseUrl和paths来解决"Cannot find module xxx or its corresponding type declarations"的问题。在compilerOptions中,将baseUrl设置为"./",表示项目的根目录,然后使用paths来配置别名和对应的路径。例如,使用"@/"来表示"src/"目录,使用"store/*"来表示"src/store/"目录。这样,当你在代码中引用模块时,可以使用别名来代替具体的路径。 另外,根据引用\[2\]中的说明,如果你在Visual Studio Code中安装了Vetur插件,它要求项目在工作区根目录,并且排在第一位。所以,如果你的项目不满足这些要求,可能会导致"Cannot find module xxx or its corresponding type declarations"的问题。解决方案是将项目文件夹拖进Visual Studio Code后,确保项目在工作区根目录,并将其排在第一位。 综上所述,你可以通过配置tsconfig.json中的baseUrl和paths来解决"Cannot find module xxx or its corresponding type declarations"的问题,并确保项目满足Vetur插件的要求。 #### 引用[.reference_title] - *1* [Cannot find modulexxx‘ or its corresponding type declarations.Vetur(2307)](https://blog.csdn.net/gaoxiaoba/article/details/117818093)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [【VSCode - Vetur 插件报错】Cannot find moduleXXX‘ or its corresponding type declarations.Vetur...](https://blog.csdn.net/zimeng303/article/details/113836969)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值