TypeScript error

TS1259: A default import of a CommonJS module without interop

  • Error TS1259
  • Tested with TypeScript 5.9

error TS1259: Module '...express/index' can only be default-imported using the 'allowSyntheticDefaultImports' flag is reported for import express from "express" when the package is CommonJS (its types use export =) and the config does not allow treating module.exports as a default export. The flag named in the message is the one to turn on.

A file named jsconfig.json turns allowSyntheticDefaultImports on by default, and module: "nodenext" implies esModuleInterop, so JavaScript projects mostly meet this error in a tsconfig.json with allowJs, or in a config that switches the default off. The example does the latter.

At a glance

CodeTS1259
MessageModule '{0}' can only be default-imported using the '{1}' flag
TypeScript's categoryerror
Listed underModules and imports
Turned off by esModuleInterop, allowSyntheticDefaultImports
Depends on module
In .js files Reported when the file is checked: checkJs in jsconfig.json, or // @ts-check at the top of the file

The message is TypeScript's own text from its diagnostic messages file (Apache-2.0); {0} and {1} are filled in by tsc for each error.

What it looks like

server.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: server.js(2,8): error TS1259: Module '"/project/node_modules/@types/express/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag 6.0.3 : differs, see why TypeScript 6.0.3, run 21 October 2026: differs from 5.9.3. error TS5107: Option 'allowSyntheticDefaultImports=false' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. server.js(2,8): error TS1259: Module '"/project/node_modules/@types/express/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag 7.0.2 : differs, see why TypeScript 7.0.2, run 21 October 2026: differs from 5.9.3. jsconfig.json(10,37): error TS5108: Option 'allowSyntheticDefaultImports=false' has been removed. Please remove it from your configuration. checked 21 October 2026
import express from "express";error TS1259: Module '"/project/node_modules/@types/express/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag

export const app = express();
A default import of a CommonJS package with synthetic defaults off.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "esnext",
    "types": ["node"],
    "moduleResolution": "bundler",
    "allowSyntheticDefaultImports": false
  },
  "include": ["*.js"]
}

What causes it

  • The imported package is CommonJS and its types say export = (Express, many older packages).
  • Neither esModuleInterop nor allowSyntheticDefaultImports is on, and module is not node16 to nodenext (which imply interop).

How to fix it

Turn on esModuleInterop

"esModuleInterop": true makes default imports of CommonJS modules work the way Node.js and bundlers run them, and implies allowSyntheticDefaultImports. With module: "nodenext" it is already on.

server.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
import express from "express";

export const app = express();
The same import with esModuleInterop on.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "esnext",
    "types": ["node"],
    "moduleResolution": "bundler",
    "esModuleInterop": true
  },
  "include": ["*.js"]
}

Under TypeScript 6.0 and 7.0

Every example on this page also runs under TypeScript 6.0.3 and 7.0.2 when this site is built. One of them reports something different from 5.9.3, the version the page describes; the ✗ on its badge links to its entry below.

allowSyntheticDefaultImports: false is deprecated, then removed

TypeScript 6.0 and 7.0 · options 6.0 deprecates and 7.0 removes

The pattern: A config that sets allowSyntheticDefaultImports (or esModuleInterop) to false, and a default import of a CommonJS package such as Express.

Why: Per the 6.0 release notes these options can no longer be false: 6.0 reports the setting as deprecated (TS5107) and still applies it, so the default import keeps its TS1259; 7.0 reports it as removed (TS5108) and always uses the safer interop, so the default import works and TS1259 is gone. Source: TypeScript 6.0 release notes: Deprecated: --esModuleInterop false and --allowSyntheticDefaultImports false.

A default import of a CommonJS package with synthetic defaults off server.js

TypeScript 5.9.3
server.js(2,8): error TS1259: Module '"/project/node_modules/@types/express/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag
TypeScript 6.0.3differs from 5.9.3
error TS5107: Option 'allowSyntheticDefaultImports=false' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
server.js(2,8): error TS1259: Module '"/project/node_modules/@types/express/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag
TypeScript 7.0.2differs from 5.9.3
jsconfig.json(10,37): error TS5108: Option 'allowSyntheticDefaultImports=false' has been removed. Please remove it from your configuration.

What works in every version: Remove the option (or set esModuleInterop: true) and keep the default import.

The example The same import with esModuleInterop on on this page shows it, with the same result under every version.

Gotchas

  • import * as express from "express" also passes the checker without interop, but calling express() on a namespace import fails at run time in Node.js's ES modules. Turn interop on instead.
  • The message names the module by its resolved path (tsc prints the full path; on this site examples live at /project).

Sources

Last reviewed 20 October 2026.