eslint 提示无法解析模块路径问题
原错误信息:Unable to resolve path to module './show'. eslint(import/no-unresolved)
项目结构如下:
my_project
│
├── node_modules
├── package.json
├── .eslintrc.json
├── src
│ ├── show.ts
│ └── index.ts
index.ts :
// 此处提示上面的错误
import show from './show'
实际上 show.ts 这个文件是存在的,但 eslint 一直提示模块不存在。
解决方法: 在 .eslintrc.json 文件中添加下面的配置
{
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
},
...
}