Node.js 5 min read

Run TypeScript natively in Node.js: a practical guide

Node.js can now run .ts files directly with built-in type stripping. What works, what does not, the recommended tsconfig and when it is a good fit.

Crest Design
Node.js logo beside a TypeScript file with types being stripped

Yes, you can now run TypeScript files directly with Node.js, with no build step and no extra packages. Built-in type stripping is enabled by default and marked stable in Node.js 24.12 and later and in Node.js 26, which became the Active LTS release on 28 October 2026. Run node server.ts and Node.js removes the type annotations and executes the JavaScript underneath.

There are limits, though. Node.js does not check types, ignores tsconfig.json and rejects TypeScript features that need code generation, such as enums. This guide explains what works, what does not, and how to set up a Node.js project so the built-in support works smoothly. Details are correct at the time of writing (November 2026).

What type stripping actually does

Type stripping is exactly what the name says. Node.js replaces inline type annotations with whitespace and runs the result. Because the code keeps the same line and column positions, stack traces point to the right place in your .ts file without source maps.

It does not type-check your code. A function that receives the wrong type will still run, just as plain JavaScript would. You still need the TypeScript compiler (tsc) or your editor to catch type errors, typically in CI and in your editor as you work.

Node.js runs your TypeScript; the TypeScript compiler still checks it.

How support has developed

Node.js version Change
22.6.0 Type stripping added behind a flag
23.6.0 and 22.18.0 Enabled by default
24.3.0 and 22.18.0 Experimental warning removed
25.2.0 and 24.12.0 Marked stable
26.0.0 --experimental-transform-types flag removed

The removal of --experimental-transform-types in Node.js 26 matters if you relied on it to run enums or namespaces. On Node.js 26, that code needs either a rewrite or a third-party tool.

What works and what does not

Supported

  • Type annotations, interfaces, type aliases and generics.
  • .ts files, which follow the same module rules as .js (so "type": "module" in package.json makes them ES modules), plus .mts (always ESM) and .cts (always CommonJS).
  • Type-only namespaces.
  • TypeScript passed through --eval or standard input.

Not supported

  • Syntax that generates code: enum declarations, namespaces with runtime code, parameter properties in constructors, and import aliases. These throw an ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX error.
  • Decorators, which cause a parser error. This rules out frameworks that depend on them, unless you use a build step.
  • .tsx files.
  • tsconfig.json settings, including paths aliases and down-levelling to older JavaScript.
  • TypeScript inside node_modules, so published packages still need to ship JavaScript.
  • The REPL, --check and inspect.

Setting up a project for native TypeScript

The Node.js documentation recommends a tsconfig.json that makes the TypeScript compiler enforce the same rules Node.js follows:

  • "erasableSyntaxOnly": true flags enums, runtime namespaces and other syntax Node.js cannot strip.
  • "verbatimModuleSyntax": true requires the type keyword on type-only imports, matching Node.js behaviour.
  • "rewriteRelativeImportExtensions": true lets you write the .ts extensions Node.js requires in relative imports.
  • "module": "nodenext" and "target": "esnext".
  • "noEmit": true if you only run the files directly, such as scripts and internal services. Leave it out if you also publish compiled JavaScript.

2. Write imports the Node.js way

File extensions are mandatory, so write import { createOrder } from './orders.ts'. Type-only imports must say so: import type { Order } from './types.ts', or import { createOrder, type Order } from './orders.ts'. A plain import of a type is treated as a value import and fails at runtime.

3. Replace path aliases with subpath imports

If your project uses tsconfig paths such as @/lib/db, switch to Node.js subpath imports defined in package.json. These must start with #, for example #lib/db.

4. Replace enums with plain objects

A common pattern is a constant object with as const plus a union type derived from it. It is erasable, works in Node.js and gives you the same autocomplete in your editor.

5. Keep type checking in CI

Add a tsc --noEmit step to your CI pipeline, so type errors block a merge even though Node.js itself would happily run the code.

When native TypeScript is a good fit

Built-in type stripping removes a build step, a dependency and a source of configuration drift. It works particularly well for:

  • Small APIs, webhook receivers and background workers.
  • Build scripts, data migrations and one-off maintenance tasks.
  • Internal tools and command-line utilities.
  • New projects where you can follow the erasable-syntax rules from day one.

It is a weaker fit for existing codebases that rely heavily on enums, decorators, parameter properties or path aliases, and for libraries published to npm, which still need compiled JavaScript. For full TypeScript support at runtime, the Node.js docs point to third-party tools such as tsx, run with npx tsx your-file.ts or node --import=tsx your-file.ts. Bundlers and frameworks with their own compilers carry on working as before.

Frequently asked questions

Is native TypeScript in Node.js ready for production?

Type stripping is marked stable in Node.js 24.12 and later and in Node.js 26. Many teams use it for services and scripts. Keep type checking in CI, and test start-up and error handling as you would with any runtime change.

Does it make my app slower?

Stripping happens when files are loaded, so the main cost is at start-up. For long-running servers, that is usually negligible. Measure it if cold starts matter, for example on serverless platforms.

Do I still need the typescript package?

Yes, for type checking and editor support. You no longer need it, or a separate runner, just to execute your code.

Need help with your Node.js project?

We build Node.js APIs, integrations and background services, and can help modernise a codebase, simplify its build or move it to a current LTS release. See our Node.js development services, the React front end and Node.js API we built for a startup incubator, and our guide to Node.js integrations for Shopify, HubSpot and CRMs. When you are ready, tell us what you are building.

Sources: Node.js documentation: Modules: TypeScript, Node.js 26.0.0 release, Node.js 26.13.0 (LTS) release.

(over to you)

Planning a build like this?

Tell us what you're building and we'll come back with ideas and next steps.