Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Problem:

Error 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

Steps to reproduction:

  • create-next-app
  • 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"]
}

Specs

  • vscode: Version 1.57.1
  • node: 14.17.1 (LTS)
  • nextjs: 11.0.1

note: I added eslint-import-resolver-typescript module, but still dint work.

Screenshot:

SS

like image 204
Nish Avatar asked Jun 29 '21 12:06

Nish


2 Answers

If you are using vscode, try to disable TypeScript › Validate in settings. This solved it for me!

Edit:

Found a more sensible approach than totally disabling validation; setting the TypeScript SDK in the Vscode setting

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

like image 77
Solly Avatar answered Oct 22 '22 06:10

Solly


Just restart your all vscode windows, that worked in my case.

like image 28
Avdhoot kadam Avatar answered Oct 22 '22 07:10

Avdhoot kadam