繁体   English   中英

'import-resolver-typescript/lib' 在 jsconfig.json 中找不到错误

[英]'import-resolver-typescript/lib' not found error in jsconfig.json

问题:

找不到错误File '/Users/nish7/Documents/Code/WebDev/HOS/frontend/node_modules/eslint-import-resolver-typescript/lib' not found. The file is in the program because: Root file specified for compilation File '/Users/nish7/Documents/Code/WebDev/HOS/frontend/node_modules/eslint-import-resolver-typescript/lib' not found. The file is in the program because: Root file specified for compilation

复制步骤:

  • 创建下一个应用程序
  • npx jsconfig.json -t nextjs

jsconfig.json

    "compilerOptions": {
        "checkJs": false,
        "resolveJsonModule": true,
        "moduleResolution": "node",
        "target": "es2020",
        "module": "es2015",
        "baseUrl": ".",
        "paths": {
            "@/components/*": ["components/*"],
            "@/styles/*": ["styles/*"],
            "@/pages/*": ["pages/*"],
            "@/utils/*": ["utils/*"],
            "@/theme/*": ["theme/*"]
        }
    },
    "exclude": [
        "dist",
        "node_modules",
        "build",
        ".vscode",
        ".next",
        "coverage",
        ".npm",
        ".yarn"
    ],
    "typeAcquisition": {
        "enable": true,
        "include": ["react", "react-dom"]
    }
}


eslint.rc

{
  "extends": ["next", "next/core-web-vitals"]
}

眼镜

  • vscode:版本 1.57.1
  • 节点:14.17.1 (LTS)
  • 下一个:11.0.1

注意:我添加了 eslint-import-resolver-typescript 模块,但仍然有效。

截屏:

党卫军

如果您使用的是 vscode,请尝试禁用TypeScript › Validate在设置中TypeScript › Validate 这为我解决了!

编辑:

找到比完全禁用验证更明智的方法; 在 Vscode 设置中设置 TypeScript SDK

"typescript.tsdk": "./node_modules/typescript/lib"

只需重新启动所有 vscode 窗口,这在我的情况下有效。

也许你还没有为打字稿安装 linter。 您可以使用 npm 全局安装它:

npm i -g eslint-import-resolver-typescript

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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