How to fix Cannot read configuration file 'tsconfig.json' in TypeScript

TypeScriptBEGINNERHIGHUpdated Dec 8, 2025ยท 141 views

TypeScript cannot locate or read your tsconfig.json file. This occurs when the configuration file is missing, in the wrong location, contains invalid JSON, or when the working directory is incorrect.

Quick fix

Fixes TS5058

ls -la tsconfig.json
  1. Verify tsconfig.json exists in your project root
  2. Create a tsconfig.json if missing
  3. Validate tsconfig.json syntax using a JSON validator
  4. Run tsc from the correct working directory
typescript โ€” error
ls -la tsconfig.json
Cannot read configuration file 'tsconfig.json'

What this error means

This error means TypeScript's compiler (tsc) tried to find and read your tsconfig.json configuration file but was unable to. The tsconfig.json file is essential for TypeScript projects as it defines compiler options, file inclusion/exclusion patterns, and project settings. When TypeScript cannot read this file, it cannot properly configure the compilation process for your project.

Typical symptoms

  • TypeScript compiler fails with configuration error on startup
  • IDE shows unable to resolve TypeScript project configuration
  • ESLint or other tools report parsing errors related to tsconfig
  • Build scripts fail when invoking tsc command
  • Different behavior when running TypeScript from different directories

Common causes

  1. tsconfig.json file is missing from the project root directory
  2. The working directory when running tsc is different from where tsconfig.json is located
  3. tsconfig.json contains invalid JSON syntax (unclosed braces, trailing commas, etc.)
  4. The extends property in tsconfig.json references a non-existent configuration file
  5. File permissions prevent TypeScript from reading the tsconfig.json file
  6. ESLint or other tools are configured to look for tsconfig.json in the wrong location
  7. tsconfig.json was moved or deleted after the build process started

How to fix "Cannot read configuration file 'tsconfig.json'"

1Verify tsconfig.json exists in your project root

First, check that tsconfig.json is present in the root directory of your TypeScript project. Use your file explorer or run this command:

bash
ls -la tsconfig.json

If the file is not found, you need to create it.

2Create a tsconfig.json if missing

If tsconfig.json doesn't exist, generate a default one using TypeScript's initialization command:

bash
npx tsc --init

This creates a valid tsconfig.json file with sensible defaults for your project. You can then customize it as needed.

3Validate tsconfig.json syntax using a JSON validator

Copy the contents of your tsconfig.json and paste it into an online JSON validator like https://jsonlint.com/ to check for syntax errors. Common issues include:

json
// Wrong - trailing comma
{
  "compilerOptions": {
    "target": "ES2020",
  }
}

// Correct
{
  "compilerOptions": {
    "target": "ES2020"
  }
}

Fix any JSON syntax errors the validator reports.

4Run tsc from the correct working directory

Ensure you're running the TypeScript compiler from the directory containing tsconfig.json. For example:

bash
cd /path/to/project
npx tsc

Don't run tsc from a parent directory unless you explicitly specify the configuration file path:

bash
npx tsc -p ./my-project/tsconfig.json
5Check extends references if using configuration inheritance

If your tsconfig.json uses the extends property, verify the referenced file exists:

json
{
  "extends": "./tsconfig.base.json",
  "compilerOptions": {}
}

Ensure tsconfig.base.json (or whatever file is referenced) exists in the same directory. If using npm packages like @tsconfig/recommended, install them first:

bash
npm install --save-dev @tsconfig/recommended
6Set tsconfigRootDir for ESLint/build tools

If you're using ESLint, ts-node, or other tools that reference tsconfig.json, configure them to find it correctly. For ESLint, update .eslintrc.js:

javascript
module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: 'tsconfig.json',
    tsconfigRootDir: __dirname,
  },
};

The tsconfigRootDir tells the tool to resolve tsconfig.json relative to the configuration file's directory, not the current working directory.

7Verify file permissions

On Unix-like systems (Linux, macOS), check that you have read permissions on tsconfig.json:

bash
ls -l tsconfig.json

If permissions are restricted (e.g., ----------), add read permission:

bash
chmod +r tsconfig.json

Advanced notes

When TypeScript searches for tsconfig.json, it starts in the specified directory and walks up the parent directory chain until it finds the file. This means you can store tsconfig.json in a parent directory and TypeScript will find it, but tools like ESLint may not perform this search and will look only in the working directory. For monorepo setups with multiple tsconfig.json files at different levels, explicitly specify the path using the -p flag: tsc -p packages/my-app/tsconfig.json. Additionally, some IDEs like VSCode cache the tsconfig.json configuration, so after fixing the file, you may need to reload the editor window to see changes take effect.

Frequently asked questions

What does "TS5058" mean?
json configuration file but was unable to. json file is essential for TypeScript projects as it defines compiler options, file inclusion/exclusion patterns, and project settings. When TypeScript cannot read this file, it cannot properly configure the compilation process for your project.
How do I fix "TS5058"?
TypeScript cannot locate or read your tsconfig.json file. This occurs when the configuration file is missing, in the wrong location, contains invalid JSON, or when the working directory is incorrect.
What causes "TS5058"?
tsconfig.json file is missing from the project root directory The working directory when running tsc is different from where tsconfig.json is located tsconfig.json contains invalid JSON syntax (unclosed braces, trailing commas, etc.)
Is the "TS5058" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading