Skip to content
Nilay Kabariya

Entry No.023·Fixes·Updated ·4 min read

Fix: TypeScript enum is not supported in strip-only mode

Node's ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX for enum, parameter properties, namespace, export = and import =. Two ways to run it unchanged, both tested.

The error, verbatim

Jump to the fix ↓
enum Color { Red, Green }
^^^^^^^^^^^^^^^^^^^^^^^^^

SyntaxError [ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX]: TypeScript enum is not supported in strip-only mode
    at parseTypeScript (node:internal/modules/typescript:68:40)
    at processTypeScriptCode (node:internal/modules/typescript:146:42)

# the same family:
SyntaxError [ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX]: TypeScript parameter property is not supported in strip-only mode
SyntaxError [ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX]: TypeScript namespace declaration is not supported in strip-only mode
SyntaxError [ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX]: TypeScript export assignment is not supported in strip-only mode
SyntaxError [ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX]: TypeScript import equals declaration is not supported in strip-only mode
✓ Reproduced on Windows 11 Pro

The fix that worked

Tell Node to transform it, no code changes:

node --experimental-transform-types src/index.ts
Not it? Every cause, tested ↓

Tested on

Node
22.18.0, 24.14.0; re-tested on 22.23.4, 24.22.1, 26.13.0
tsx
4.23.15
OS
Windows 11 Pro

✓ Last re-run on GitHub Actions · see the run · all repros

You ran node file.ts and Node stopped at one line. Your code isn’t wrong. Node just refuses to generate anything, and that line needs generated JavaScript.

The fix

Keep the code as it is, and tell Node to transform it:

node --experimental-transform-types src/index.ts

Node prints this every time you use it:

ExperimentalWarning: Transform Types is an experimental feature and might change at any time

To hide it, add a second flag:

node --experimental-transform-types --disable-warning=ExperimentalWarning src/index.ts

For npm scripts or tools that start Node for you, the flag also works from the environment: NODE_OPTIONS=--experimental-transform-types. I checked that it has the same effect.

Or run it with tsx, which compiles instead of stripping, so none of this syntax is a problem:

npm i -D tsx
npx tsx src/index.ts

Which line Node means

The message names the construct, and the carets under the code point at it. Here’s the whole family, each one reproduced:

The error says Your code has Plain-JavaScript version
enum is not supported enum Color { Red, Green } const Color = { Red: 0, Green: 1 } as const;
parameter property is not supported constructor(private name: string) {} a private name: string; field, set in the constructor
namespace declaration is not supported namespace Config { export const port = 3000; } const Config = { port: 3000 };
export assignment is not supported export = add; (in a .cts file) module.exports = add;
import equals declaration is not supported import path = require("node:path"); const path = require("node:path");

Why it happens

Since Node 22.18, node file.ts works out of the box, but not by compiling. Node deletes the type annotations and runs what’s left. That’s “strip-only mode”.

Most TypeScript survives that. These five don’t, because they don’t disappear when the types are removed: an enum has to become a real object, a parameter property has to become an assignment, a namespace has to become a wrapper. Stripping can’t write that code, so Node stops and names the construct.

--experimental-transform-types switches Node from stripping to actually transforming, which is why the same files run with it.

Which fix to pick

  • One script, or you don’t want to touch working code: the flag, on Node 22 or 24. It’s one word in the command, but it doesn’t exist on Node 26.
  • An app you run every day, or you’d rather avoid an experimental flag: tsx.
  • Code that should run on plain node for years: rewrite the few lines using the table above. That’s also the only route with no flag and no dependency.

If you rewrite, turn on erasableSyntaxOnly in tsconfig.json so the type checker flags these before Node does. That produces a different error in your editor: This syntax is not allowed when ‘erasableSyntaxOnly’ is enabled (TS1294), which shows the same rewrites in more detail.

What didn’t work

How this was tested

Five small files, one construct each (enum, a constructor parameter property, a namespace with a value in it, export = in a .cts file, import x = require() in a .cts file), plus a type-only namespace as a control. Each was run with plain node, with --experimental-transform-types, through NODE_OPTIONS, with tsx 4.23.15, and in its rewritten form, on Node 24.14.0. On Node 22.18.0 each ran plain, with the flag, and rewritten. All on Windows 11 Pro. Every error and output above is copied from those runs.

November 2, 2026: all five constructs, the flag, NODE_OPTIONS, tsx 4.23.15, the rewrites and the types-only namespace were re-run on Node 22.23.4, 24.22.1 and 26.13.0 (GitHub Actions ubuntu-latest). Everything matched on 22 and 24. On 26.13.0 the five files failed the same way, tsx and the rewrites still worked, and --experimental-transform-types was rejected as a bad option. The script and output are public.

— N.K., end of entry No.023

Useful? Pass it on:Post on XFollow @EmotionalMatter

Related entries

  1. No.014

    TS1294: syntax not allowed with 'erasableSyntaxOnly', fixed

    TS1294: TypeScript rejects your enum, namespace or constructor shorthand. Why new projects turn this on, what each piece becomes, and when to switch it off.

    > src/a.ts(1,6): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.

    FIXED4 min
  2. No.013

    Fix: ERR_MODULE_NOT_FOUND Cannot find module in ES modules

    Node can't find a file that is clearly there. What ES modules changed about relative imports, why TypeScript path aliases break at runtime, and what to change.

    > node:internal/modules/esm/resolve:275

    FIXED4 min
  3. No.012

    Unknown file extension ".ts" (ERR_UNKNOWN_FILE_EXTENSION)

    Node refuses to run your TypeScript file. The version where this stops happening, what ts-node has to do with it, and the one-line way to run .ts today.

    > node:internal/modules/esm/get_format:189

    FIXED5 min

tip: paste the exact error text