Skip to content
Latchkey

TS1192: Module has no default export - in CI

You used a default import on a module that exports only named members (or a CommonJS module without interop).

What this error means

Type-checking fails with TS1192 naming the module that lacks a default export.

tsc
src/app.ts(1,8): error TS1192: Module '"./helpers"' has no default export.

Diagnose it: which tsconfig and which compiler?

A TypeScript error that appears only in CI usually means the runner is compiling with a different config or a different compiler version than your editor. Your editor uses the workspace TypeScript and the nearest tsconfig.json; CI uses whatever the lockfile resolved and whatever config the build script names.

Terminal
# what CI will actually use
npx tsc --version
npx tsc --showConfig | head -40

# which files are in the program (a missing include is a common cause)
npx tsc --listFiles | wc -l

# type-check only, no emit, same as most CI gates
npx tsc --noEmit

Common causes

How to fix it

Use a named import

  1. Import the named member instead of a default
ts
import { helper } from './helpers'

Enable esModuleInterop for CJS defaults

  1. Turn on esModuleInterop so synthetic default imports work for CommonJS
tsconfig.json
{
  "compilerOptions": { "esModuleInterop": true }
}

Pin the compiler so unrelated updates cannot break the gate

TypeScript adds errors in minor releases. An unpinned compiler turns a routine dependency update into a red build on code nobody touched, which is the most common false alarm in a TypeScript CI pipeline.

package.json
// package.json
{
  "devDependencies": {
    "typescript": "5.6.3"   // exact, not ^5.6.3
  }
}

How to prevent it

  • Match import style to the module shape and enable esModuleInterop when consuming CommonJS.

Frequently asked questions

How do I fix TS1192: module has no default export?
There are 2 fixes depending on which cause you have: use a named import and enable esmoduleinterop for cjs defaults. Work through them in order, since the first is the most common.
What does TS1192: module has no default export actually mean?
Type-checking fails with TS1192 naming the module that lacks a default export.
How do I stop TS1192: module has no default export happening again?
Match import style to the module shape and enable esModuleInterop when consuming CommonJS.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card