question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing error: Cannot read file tsconfig.json, when it's in subfolders and not in root

See original GitHub issue

Hi, I have nested subprojects, with individual esling and tsconfig configurations, which get parsed correctly from command line, but not from the extension.

You can check the repo in its current state at: https://github.com/fcole90/fullstack_open_2020_part9/tree/f56f5c6c2df77b80c2f7e4df42c07fe6718ff53a

Details

I have a root folder fullstack_open_2020_part9, which contains some subfolders, each with a separate .eslintrc and an associate tsconfig.json. If I run eslint --ext .ts . within each of the subfolders I get the correct parsing. However, the extension doesn’t read the right configuration file: e.g. in the file fullstack_open_2020_part9/patientor/backend/index.ts it reports Parsing error: Cannot read file '/home/fabio/Projects/aalto/fullstack_open_2020_part9/tsconfig.json' but I would be expecting it to check /home/fabio/Projects/aalto/fullstack_open_2020_part9/patientor/backend/tsconfig.json instead.

Note

I used this same dir structure for other projects (most of those “fullstack_open_2020_part*” you can find among my repos) which didn’t use Typescript, and .js files were parsed correctly without any need to customise ESlint options.

I think this issue might be related to using this extension with an eslint file pointing to a parserOptions.project with a relative link like mine:

    "parserOptions": {
        "project": "./tsconfig.json"
    }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

73reactions
fcole90commented, Feb 8, 2021

Solved by adding .vscode/settings.json at the root of the project with the following content (as you suggested):

{
  "eslint.workingDirectories": [
    "./part_b",
    "./part_c_patientor/frontend",
    "./part_c_patientor/backend",
    "./part_d",
  ]
}

Link to repo with fix: https://github.com/fcole90/fullstack_open_2020_part9

19reactions
glen-84commented, Apr 1, 2021

@dbaeumer,

I was able to fix or workaround the issue by using:

project: path.join(__dirname, "tsconfig.eslint.json")

… to force ESLint (or probably TS-ESlint) to use the file in the current directory. It’s a bit strange that it doesn’t do this by default though.

Perhaps PhpStorm changes into the configuration directory before running ESLint.

Read more comments on GitHub >

github_iconTop Results From Across the Web

214 - Stack Overflow
Parsing error : Cannot read file 'd:\test\testproject\tsconfig.app.eslint.json'.eslint One of the major issues I faced here because of the ...
Read more >
Parsing Error: Cannot read file 'tsconfig.json' | bobbyhadz
To solve the error "Parsing Error: Cannot read file 'tsconfig.json'", update your .eslintrc.js file to set the tsconfigRootDir option to __dirname to force ......
Read more >
Node.js – Parsing error: Cannot read file '…/tsconfig.json'.eslint
By default, the project s (in parserOptions ) are resolved relative to the current working directory. If you run eslint in a different...
Read more >
WebStorm incorrectly builds the path to eslint's parserOptions ...
WebStorm displays the following error: ESLint: Parsing error: Cannot read file '/<path_to_project>/server/server/tsconfig.eslint.json'. image.png
Read more >
TSConfig Reference - Docs on every TSConfig option
It has no interaction with the include , exclude , or files tsconfig.json settings. Note that TypeScript will never write an output file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found