现象

原因分析

这个错误只和typescript有关系,是由于ts默认情况下不认识less文件。

解决办法

步骤一

在根目录下创建externals.d.ts文件,并填写入以下内容:

declare module '*.less' {const resource: {[key: string]: string};export = resource;
}
步骤二

然后,在根目录中找到tsconfig.json文件,在includes里添加刚刚创建的externals.d.ts文件的路径:

// tsconfig.json
{compilerOptions: {...}includes: ['./externals.d.ts']
}

保存后,VSCODE编译器自动解析,OK,不再下滑红线警告了

Cannot find module ‘./index.less‘ or its corresponding type declarations相关推荐

  1. webstorm报错:TS2307: Cannot find module ‘./App.vue‘ or its corresponding type declarations

    错误描述 在使用ts后,webstrom报以下错误 TS2307: Cannot find module './App.vue' or its corresponding type declarati ...

  2. Cannot find module ‘axios;‘ or its corresponding type declarations.ts(2307)

    问题描述 我在ts文件中导入刚才安装好的axios,报错了,报错信息如下: 解决方法 按下键盘ctrl+shift+p,在弹出的窗口输入 typescript 选择Select TypeScript ...

  3. 【VSCode - Vetur 插件报错】Cannot find module ‘XXX‘ or its corresponding type declarations.Vetur(2307)

    Cannot find module '@/utils/request' or its corresponding type declarations.Vetur... 原因分析 解决方案 原因分析 ...

  4. vue+ts项目中import图片时报错Cannot find module ‘xxx‘ or its corresponding type declarations

    TS项目中import图片时报错Cannot find module 'xxx' or its corresponding type declarations 在vue+ts项目中使用import的形 ...

  5. vue3 setup + ts + vite 项目问题解决:Cannot find module ... or its corresponding type declarations.(ts2307)

    昨日我尝试使用vue3 setup + ts + vite进行vue3项目的实现,遇到此问题: Cannot find module ... or its corresponding type dec ...

  6. TS2307: Cannot find module ‘@/assets/home/banner1.webp‘ or its corresponding type declarations.

    最近在用typescript + webpack 重构项目,每次打包都会出现下面报错: 第一次以为是这个路径别名的问题,改为相对路径还是报错 尝试过把项目中使用这段图片路径的img标签注释掉,重新打包 ...

  7. Cannot find module ‘echarts‘ or its corresponding type declarations.

    Vue3+ts 在引入echarts会报错 Cannot find module 'echarts' or its corresponding type declarations. 先npm i @t ...

  8. Cannot find module ... or its corresponding type declarations.(ts2307)

    vue3+ts项目出现这样的编译提示,红色下划线 Cannot find module ... or its corresponding type declarations.(ts2307) 解决方法 ...

  9. 安装vite框架,报错“Cannot find module ‘./App.vue‘ or its corresponding type declaration” 问题解决方法

    代码编辑器:vscode ,使用vue3,所以安装了 Volar 插件,可以使 vue 代码高亮显示,不同颜色区分代码块,以及语法错误提示等 提示:如果使用的是vue2,则使用 Vetur 插件:使用 ...

最新文章

  1. 深入浅出Java垃圾回收机制
  2. Rhel6服务器时间任务浅谈
  3. mysql 5.6 emoji_让MySQL支持Emoji表情 mysql 5.6
  4. linux 启动rabbitmq 报错:
  5. thymeleaf依赖_玩转SpringBoot集成 Thymeleaf 模版引擎
  6. 小程序 bindtouchmove 使用拖动按钮 页面跟着滑动并拖动卡顿感 问题
  7. SpringBoot—Entity父子类表@Inheritance和@MappedSuperclass
  8. redis入门——安装篇
  9. 怎么将layui导入php中,layui怎么导入Excel
  10. Rabbit MQ 配置
  11. [设计模式-行为型]迭代器模式(Iterator)
  12. Lync Server 2010企业版系列PART1:基础构建
  13. UE4 VR中一种比较清晰的UI制作方式
  14. c ++ strstr_在C / C ++中使用strstr()的指南
  15. 51Nod - 1051(思维)
  16. HDU 2549 壮志难酬
  17. 安卓智能手机完全装机手册,让安卓拥有无限可能!
  18. HTTP/HTTPS/SOCKS5协议的区别
  19. 多拨测试软件,openwrt一线多拨网速叠加操作(网友提供)测试速度请用的方式不要用360那些测试软件...
  20. ssm框架体检管理系统源码+文档

热门文章

  1. 使用SQL.js访问SQLite
  2. 绘图 | 绘制框架结构图
  3. 使用余弦相似度计算文本相似度
  4. c语言的递归算法流程图,递归算法C语言全解.ppt
  5. 教娘学电脑(二十三)
  6. Docker容器设置端口映射的方法
  7. Android 三种方式播放视频和百度直播
  8. 【论文翻译】YOLOv2:YOLO9000_Better, Faster, Stronger
  9. Java成员变量(全局变量)和局部变量
  10. 微信小程序_wxcharts(图表不随页面滑动因素之一)