13

I was already looking for an answer here on stackoverflow jsconfig.json gives ts errors. I tried:

  1. set
"exclude": ["node_modules"]

in jsconfig.json

  1. set
"noEmit": true 

in jsconfig.json in "compilerOptions"

  1. delete node_moduls and package-lock.json and after npm install

npm install --save @types/dotenv

Nothing helped :(

I work just with js files or jsx. My OS ubuntu (Focal Fossa). Сan someone explain to me from where the error coming from. And what does it have to do with TypeScript .And how to get rid of it completely? What else can I do besides what I have already done above?

Full error message is:

{
    "resource": "path/jsconfig.json",
    "owner": "typescript",
    "severity": 8,
    "message": "File 'path/node_modules/agent-base/dist/src/index' not found.\n  The file is in the program because:\n    Root file specified for compilation",
    "source": "ts",
    "startLineNumber": 1,
    "startColumn": 1,
    "endLineNumber": 1,
    "endColumn": 2
}
Gregory Kafanov
  • 339
  • 1
  • 3
  • 11
  • I am also getting this exact same problem and so far no solution I have come across has worked.... – Hazy Nov 10 '21 at 01:37
  • I have the exact same problem but no answers yet. Ignore the answer I posted and then deleted. I discovered that it didn't work after all. – Justin Warkentin Nov 16 '21 at 12:10

3 Answers3

9

You can use the following method as a workaround in Visual Studio. File > Preferences > Settings, type "typescript validate" in the search bar, and uncheck the result.

B. Toprak
  • 131
  • 2
  • 1
    Since this answer pops up when searching for the same issue but _with_ typescript files and a `tsconfig.json`, this might sound obvious but don’t disable this setting if you _are_ working with typescript files. I haven’t yet found the solution however. – Jens Bodal Mar 20 '22 at 16:48
2

I actually had similar problem which I managed to fix by changing TypeScript version in VS Code. Just open any JavaScript file and click on "Select language mode" button in the bottom right corner. It should allow you to select workspace TS version instead of global one.

Romeo Zet
  • 61
  • 3
0

Remove any comment from your .json file. Comments, i.e. // my comment are not valid JSON.

Michael Brenndoerfer
  • 3,483
  • 2
  • 39
  • 50