oxc-project/oxc · error · anyhow::Error

TS5058

TS5058

Error message

The specified path does not exist: '{}'.

What it means

Raised during tsc-style compilation in resolve_config_file: a tsconfig.json was auto-discovered from the current directory, but input files were also passed on the command line. tsc semantics give precedence to explicit file arguments, so the config would be silently ignored; this bail surfaces that conflict instead of compiling with unexpected settings.

Source

Thrown at crates/oxc_type_checker/src/execute/tsc.rs:96

        let file_or_directory = to_path(cwd, project);
        if file_or_directory.is_dir() {
            // A directory: look for `tsconfig.json` inside it.
            let config_file = file_or_directory.join("tsconfig.json");
            if config_file.is_file() {
                Ok(Some(config_file))
            } else {
                // TS5081
                bail!(
                    "Cannot find a tsconfig.json file at the current directory: {}.",
                    config_file.display()
                );
            }
        } else if file_or_directory.exists() {
            // An explicit config file (need not be named `tsconfig.json`).
            Ok(Some(file_or_directory))
        } else {
            // TS5058
            bail!("The specified path does not exist: '{}'.", file_or_directory.display());
        }
    } else if let Some(config_file) = find_config_file(cwd) {
        if command.files.is_empty() {
            Ok(Some(config_file))
        } else {
            // TS5112: a tsconfig.json is present but source files were also specified.
            bail!(
                "tsconfig.json is present but will not be loaded if files are specified on \
                 commandline. Use '--ignoreConfig' to skip this error."
            );
        }
    } else if command.files.is_empty() {
        // TS5081 — `tsc` prints version + help here; we report the missing config instead.
        bail!("Cannot find a tsconfig.json file at the current directory: {}.", cwd.display());
    } else {
        // Source files with no config file anywhere: compile them directly.
        Ok(None)
    }

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Remove the explicit file arguments so the discovered tsconfig.json drives the compilation
  2. Pass --ignoreConfig to intentionally skip config loading and suppress this error
  3. Pass an explicit config file path via --project instead of relying on auto-discovery
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_type_checker/src/execute/tsc.rs:96 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/c166f33ba96d5c0d. Report an issue: GitHub.