Skip to main content
You can write code that’s valid TypeScript directly in Node.js without the need to transpile it first.
If your source code contains only erasable TypeScript syntax, you can execute TypeScript code without any flags:
node example.ts
You can now run TypeScript code directly in Node.js without the need to transpile it first, and use TypeScript to catch type-related errors. You can disable type stripping via the --no-experimental-strip-types flag if needed:
node --no-experimental-strip-types example.ts
In v22.7.0 the flag --experimental-transform-types was added to enable TypeScript-only syntax that requires transformation, like enums and namespace.
Enabling --experimental-transform-types automatically implies that --experimental-strip-types is enabled, so there’s no need to use both flags in the same command.
node --experimental-transform-types another-example.ts
This flag is opt-in, and you should only use it if your code requires it.

Constraints

The support for TypeScript in Node.js has some constraints to keep in mind. You can get more information in the API docs.

Configuration

The Node.js TypeScript loader (Amaro) does not need or use tsconfig.json to run TypeScript code.
We recommend configuring your editor and tsc to reflect Node.js behavior by creating a tsconfig.json using the compilerOptions listed in the Node.js TypeScript docs, and using TypeScript version 5.7 or higher.

Build docs developers (and LLMs) love