Upgrades and deprecations
Run TypeScript Natively in Node.js: What Type Stripping Runs and What Breaks
In short
You can run TypeScript natively in Node.js with type stripping on 22.18.0 or later, with no flag, as long as the file uses only erasable syntax. Node replaces types with whitespace and does no type checking. Enums, runtime namespaces, parameter properties and import aliases fail, imports need the .ts extension, and tsconfig.json is ignored.
Which Node.js versions run .ts files without a flag
The history table in the Node.js TypeScript docs (read in the v26.13.1 edition) tracks the feature through several lines. Type stripping arrived in v22.6.0 behind a flag, was turned on by default in v23.6.0 and v22.18.0, stopped printing the experimental warning in v24.3.0 and v22.18.0, and was marked stable in v25.2.0 and v24.12.0. The module page now shows Stability 2, Stable.
In the table that closes this section, the rows for 24 and 26 follow from the 23.6.0, 24.3.0 and 24.12.0 entries, since later lines carry those changes forward. On anything older than 22.18.0, the Learn page says to pass --experimental-strip-types. The release table on nodejs.org lists 22, 24 and 26 as LTS on 29 November 2026, so every supported LTS line can run erasable TypeScript today. Which line to move to next, and when, is covered in the Node.js annual release schedule from version 27.
| Release line | No flag needed from | No warning from | Marked stable |
|---|---|---|---|
| Node.js 22 (LTS) | 22.18.0 | 22.18.0 | Not listed for this line |
| Node.js 24 (LTS) | Every 24.x release | 24.3.0 | 24.12.0 |
| Node.js 26 (LTS) | 26.0.0 | 26.0.0 | 26.0.0 |
What type stripping runs and what breaks
Node only removes inline types. Anything that would make TypeScript emit new JavaScript fails, because the docs say Node intentionally does no code generation. It throws ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX for the syntax it refuses.
The enum failure is the one most teams meet first; the strip only mode enum error has its own page. The old escape hatch, --experimental-transform-types, added in v22.7.0, was removed in v26.0.0 according to the same history table, so on Node 26 the choice is to rewrite the syntax or use a separate runner. The full list from the docs and the Learn page follows.
| Syntax | Result under type stripping |
|---|---|
| Type annotations, interfaces, type aliases | Yes; replaced with whitespace |
| `import type` and inline `type` imports | Yes, and required for type only imports |
| Namespace that only exports types | Yes |
| `enum` declarations | No |
| Namespace with runtime code | No |
| Parameter properties (`constructor(public x: number)`) | No |
| Import aliases | No |
| Decorators | No; parser error until JavaScript supports them natively |
| `.tsx` files | No; unsupported |
| tsconfig `paths` aliases | No; use subpath imports that start with `#` |
Imports, file extensions and module type
Three rules catch people moving from a bundler or ts-node setup.
- Extensions are mandatory:
import './file.ts', neverimport './file', and the same holds forrequire('./file.ts'). The tsconfig optionallowImportingTsExtensionsletstscaccept those specifiers; the compiler's complaint about them is covered on this import extension page. - Type imports need the
typekeyword. Without it Node treats the import as a value import and fails at runtime. The docs point toverbatimModuleSyntaxto maketscenforce the same rule. - Module type follows the JavaScript rules:
.tsfiles act like.jsand need"type": "module"in the nearest package.json forimportsyntax,.mtsfiles always run as ES modules and.ctsfiles always run as CommonJS. Node will not convert one module system to the other. - Path aliases from tsconfig are not rewritten and produce an error. If your code leans on them, the paths alias page explains the build side, and the Node docs suggest subpath imports as the nearest runtime feature.
Checked against: source 1
Running TypeScript natively in Node.js still needs a type check
Node does not type check anything. The Learn page describes a common setup: run node directly for quick feedback and run tsc --noEmit as a separate command or CI job. It also says plainly that running a .ts file with node is not the same as running tsc.
The API docs recommend TypeScript 5.8 or newer with target set to esnext, module set to nodenext, plus rewriteRelativeImportExtensions, erasableSyntaxOnly and verbatimModuleSyntax all true, and noEmit when you only execute the .ts files. The TypeScript reference says erasableSyntaxOnly errors on most TypeScript constructs that have runtime behavior, which is exactly the list Node refuses, so the editor flags an enum before Node does.
{
"compilerOptions": {
"noEmit": true,
"target": "esnext",
"module": "nodenext",
"rewriteRelativeImportExtensions": true,
"erasableSyntaxOnly": true,
"verbatimModuleSyntax": true
}
}A worked example: making one file erasable
Here is a small file in the style many services use, with the two constructs Node rejects. One way to make it erasable keeps the same runtime shape with plain JavaScript and a type alias; the TypeScript names stay for the editor. The before and after versions are in the block at the end of this section.
With erasableSyntaxOnly on, tsc --noEmit points at every remaining spot, which is faster than discovering them one crash at a time. If you need sample types for request bodies, the JSON to TypeScript converter emits interfaces, which strip cleanly.
// Before: fails under type stripping
enum Level { Info = 'info', Warn = 'warn' }
class Logger {
constructor(private prefix: string) {}
}
// After: only erasable syntax
const Level = { Info: 'info', Warn: 'warn' } as const;
type Level = (typeof Level)[keyof typeof Level];
class Logger {
private prefix: string;
constructor(prefix: string) { this.prefix = prefix; }
}Limits and edge cases before you rely on native TypeScript
A few rules in the docs only bite in particular setups, such as containers, debug sessions or monorepos. I would read this list against how your service actually starts before switching its start script to plain node.
- Files under any
node_modulespath are refused. The docs say this is deliberate, to discourage publishing packages as TypeScript, so libraries still ship JavaScript. - TypeScript syntax is unsupported in the REPL,
--checkandinspect. It works with--evaland STDIN, with the module type set by--input-type. - The parser needs WebAssembly. Without it Node throws
ERR_WEBASSEMBLY_NOT_SUPPORTEDand has no fallback parser, which matters on hardened or unusual builds. - No source maps are produced, and none are needed, because the whitespace swap keeps line and column numbers intact.
- To turn the feature off, use
--no-strip-types. For full TypeScript, including tsconfig, the docs show a third party runner such as tsx. - This page reflects the docs as read on 29 November 2026. Recheck the history table after each major release. Older upgrade notes live in moving an old app to the current LTS and the TSLint to ESLint switch, with the rest on the upgrades hub.
Checked against: source 1
What else do people ask?
Can Node.js run TypeScript without a flag?
Yes, from v22.18.0 and v23.6.0 onward, for files that use only erasable syntax. Older releases need --experimental-strip-types.
Does Node.js type stripping check types?
No. It replaces types with whitespace and runs the result. Run tsc --noEmit separately, for example in CI.
Why does an enum fail when I run TypeScript natively in Node.js?
An enum needs generated JavaScript, and type stripping never generates code. Node throws ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX; rewrite it or use a separate runner.
Is --experimental-transform-types still available?
The Node.js docs history says it was added in v22.7.0 and removed in v26.0.0.
Does Node read tsconfig.json when it strips types?
No. Node ignores tsconfig.json, so paths and down-leveling settings do nothing at runtime. Keep the file for your editor and tsc.
Can I import a .ts file without the extension under type stripping?
No. Extensions are mandatory in import, import() and require().
Sources
- Node.js documentation, Modules, TypeScript (v26.13.1), fetched 2026-11-29
- Node.js Learn, Running TypeScript natively, fetched 2026-11-29
- Node.js, Previous releases (release status table), fetched 2026-11-29
- TypeScript TSConfig reference, erasableSyntaxOnly, fetched 2026-11-29
Keep reading
Read next
- ts-node cannot run .tsx filesFix: .tsx files are unsupported (Node.js type stripping)
- Next.js 16 Upgrade: middleware to proxy and Other FixesFix: Expected 2 arguments, but got 1.
- Next.js middleware breaks when it imports Node.js cryptoFix: Middleware or a package it imports fails to build because the Edge runtime does not suppor