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
Tested on
- Node
- 22.18.0, 24.14.0
- tsx
- 4.23.15
- OS
- Windows 11 Pro
Contents
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.tsNode prints this every time you use it:
ExperimentalWarning: Transform Types is an experimental feature and might change at any timeTo hide it, add a second flag:
node --experimental-transform-types --disable-warning=ExperimentalWarning src/index.tsFor 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. It’s one word in the command.
- An app you run every day, or you’d rather avoid an experimental flag: tsx.
- Code that should run on plain
nodefor 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.
— N.K., end of entry No.025