TS1259: Module can only be default-imported using the 'esModuleInterop' flag TypeScript Origin: On your device OSI layer 7 · Application Last updated 5 Nov 2026

TypeScript: error TS1259: Module '"express"' can only be default-imported using the 'esModuleInterop' flag

You default-import a CommonJS module that uses export =, but esModuleInterop isn't enabled.

Exact message you may see error TS1259: Module '"express"' can only be default-imported using the 'esModuleInterop' flagcan only be default-imported using the 'esModuleInterop' flagTS1259 esModuleInteropts(1259) Module can only be default-imported using the 'allowSyntheticDefaultImports' flag
Seen on: TypeScript Node.js

Meaning

Enable "esModuleInterop": true (and allowSyntheticDefaultImports) in tsconfig, or import with import express = require("express") / import * as express. Modern templates enable it by default; also align the bundler/Node ESM interop behaviour.

Common causes

  • esModuleInterop false/missing
  • CJS lib with export = default-imported
  • Mixed module settings (module: commonjs vs nodenext)
  • Old tsconfig
  • ts-node using another config

⚡ Quick fix

  1. "esModuleInterop": true in compilerOptions
  2. import * as x from "x" as an alternative
  3. Check the tsconfig ts-node/ts-jest uses

Detailed fix by platform

TypeScript

  1. { "compilerOptions": { "esModuleInterop": true, "allowSyntheticDefaultImports": true } }

How to diagnose

  1. Flag — Enabled?
  2. Module — export =?
  3. Tooling — Same config?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Cannot find module './App.vue' or its corresponding type declarations — TypeScript: error TS2307: Cannot find module './App.vue' or its corresponding type declarations. (Vue)Cannot find module '.…ERR_IMPORT_ATTRIBUTE_MISSING — TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module needs an import attribute of "type: json" (Node.js)ERR_IMPORT_ATTRIBUTE_…ERR_PACKAGE_PATH_NOT_EXPORTED — Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './x' is not defined by "exports" (Node.js)ERR_PACKAGE_PATH_NOT_…ERR_REQUIRE_ESM — Error [ERR_REQUIRE_ESM]: require() of ES Module not supported (Node.js)ERR_REQUIRE_ESMSyntaxError import — SyntaxError: Cannot use import statement outside a module (Node.js)SyntaxError importTS1005: ';' expected / ',' expected (syntax error) — TypeScript: error TS1005: ';' expected. (TypeScript)TS1005: ';' expected …TS1128: Declaration or statement expected — TypeScript: error TS1128: Declaration or statement expected. (TypeScript)TS1128: Declaration o…TS1192: Module has no default export — TypeScript: error TS1192: Module '"./utils"' has no default export. (TypeScript)TS1192: Module has no…TS1259: M…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.