37

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

Mike K.
  • 637
  • 1
  • 5
  • 18

6 Answers6

24

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

Salman
  • 588
  • 4
  • 10
15

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

ETHIO CODE
  • 151
  • 1
  • 3
9

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.

Mat Schaffer
  • 1,634
  • 1
  • 15
  • 24
3

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"],
Kareem Dabbeet
  • 3,838
  • 3
  • 16
  • 34
2

Try to install and rebuild project, Hope this will help,

 npm install --save @types/dotenv
Atul Bansode
  • 211
  • 1
  • 5
  • Thanks for the suggestion, but I just initialized github repo and the problem disappeared. If the problem will appear again I'll try your solution. – Mike K. Mar 30 '21 at 11:19
  • 1
    I sorta figured it out, the error message appears on a fresh start (when I run my PC and open VSCode) and the error message disappears once I commit changes to my GitHub repo. Do you have any idea why would it be like that? – Mike K. Mar 30 '21 at 16:42
  • 1
    Strange behavior, not sure why this, but I will suggest install 'types' as suggested above or delete node_modules and package-lock.json and install fresh npm. – Atul Bansode Mar 31 '21 at 03:58
  • 2
    adding the types manually gives warning `npm WARN deprecated @types/dotenv@8.2.0: This is a stub types definition. dotenv provides its own type definitions, so you do not need this installed.` – Dave Sag Apr 15 '21 at 09:41
0

This error usually comes from different @types (typescript) folders with conflicting versions try to delete the folder from folder & see what happens.

Pvria Ansari
  • 406
  • 4
  • 20