medusajs/medusa · warning

Warning: could not read ${tsconfigBasePath}, using default c

Error message

Warning: could not read ${tsconfigBasePath}, using default compiler options

What it means

Before creating the TypeScript program, the http-types-generator reads the tsconfig specified in its config to inherit compiler options (paths, target, jsx...). If the tsconfig file cannot be read (missing or unreadable), it warns and falls back to hardcoded defaults (ES2021, Node16...), which may break path alias resolution.

Source

Thrown at packages/cli/http-types-generator/src/core/program-factory.ts:22

import { Config } from "../config"

export interface ProgramContext {
  program: ts.Program
  checker: ts.TypeChecker
}

export class ProgramFactory {
  /**
   * Reads and parses the project's TypeScript compiler options from the
   * tsconfig file specified in config (defaults to `tsconfig.json`).
   */
  private static getBaseCompilerOptions(): ts.CompilerOptions {
    const projectRoot = FsHelpers.getProjectRoot()
    const tsconfigBasePath = path.join(projectRoot, Config.get().tsconfig)

    const configStr = ts.sys.readFile(tsconfigBasePath)
    if (!configStr) {
      console.warn(
        `Warning: could not read ${tsconfigBasePath}, using default compiler options`
      )
      return {
        target: ts.ScriptTarget.ES2021,
        module: ts.ModuleKind.Node16,
        moduleResolution: ts.ModuleResolutionKind.Node16,
        esModuleInterop: true,
        skipLibCheck: true,
        strictNullChecks: true,
        resolveJsonModule: true,
        allowJs: true,
      }
    }

    const parsed = ts.parseJsonConfigFileContent(
      JSON.parse(configStr),
      ts.sys,
      projectRoot

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Set the correct tsconfig path in http-types config: { "tsconfig": "./tsconfig.app.json" }
  2. Verify the path is relative to the project root detected by FsHelpers.getProjectRoot
  3. Re-run and confirm no warning

Example fix

// before
{ "tsconfig": "tsconfig.json" }

// after
{ "tsconfig": "./tsconfig.app.json" }
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from "fs"
const tsconfig = require("./http-types.config.json").tsconfig ?? "tsconfig.json"
if (!existsSync(tsconfig)) throw new Error(`tsconfig not found: ${tsconfig}`)

Prevention

When it happens

Trigger: Config points to a non-existent tsconfig path, e.g. "tsconfig": "tsconfig.json" when the project uses tsconfig.app.json, or the file lacks read permissions.

Common situations: Running the generator from a workspace root where the relative tsconfig path resolves differently; monorepo setups with nested tsconfigs.

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/2db7711627080235. Report an issue: GitHub.