Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jsconfig.json gives ts errors

I am having jsconfig.json in my root directory using Nuxt.js project. And I am having an error:

File '/home/mike/Documents/nuxt/node_modules/dotenv/types' not found.
  The file is in the program because:
    Root file specified for compilation

Actually 5 errors in a first line of jsconfig.json: Errors

I don't even use typescript and I didn't set any typescript options while creating Nuxt.js project

jsconfig.json content:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "~/*": ["./*"],
      "@/*": ["./*"],
      "~~/*": ["./*"],
      "@@/*": ["./*"]
    }
  },
  "exclude": ["node_modules", ".nuxt", "dist"]
}

I don't understand where they come from. How do I get rid of this errors? There's no option quick fix so I can't ignore errors for entire file

like image 467
Mike Oxhuge Avatar asked Mar 30 '21 09:03

Mike Oxhuge


4 Answers

After trying several solutions, I have just added "exclude": ["node_modules"] and restarted VScode. The error went away.

like image 53
Salman Avatar answered Oct 16 '22 19:10

Salman


Just reload VSCode by typing ctrl + shift + p then type reload window and it should work.

like image 11
ETHIO CODE Avatar answered Oct 16 '22 19:10

ETHIO CODE


I ran into this and just exiting and relaunching VSCode (from the icon) seemed to fix it.

I'd originally started via code . so I'm thinking perhaps the instance with the error had picked up a weird env var from my terminal.

like image 9
Mat Schaffer Avatar answered Oct 16 '22 19:10

Mat Schaffer


In my case the problem was that the project is in a subfolder inside monorepo.

So the solution was changing it into add ./ before node_modules:

"exclude": ["./node_modules", ".nuxt", "dist"],
like image 3
Kareem Dabbeet Avatar answered Oct 16 '22 19:10

Kareem Dabbeet