ts-node
TypeScript execution environment for Node.js
TLDR
SYNOPSIS
ts-node [-P config] [--transpile-only] [--swc] [--esm] [options] [file] [args]
DESCRIPTION
ts-node is a TypeScript execution engine for Node.js that compiles and runs TypeScript files on-the-fly without a separate build step. By default it performs full type checking at runtime, reporting type errors before execution begins.The --transpile-only mode skips type checking for significantly faster startup, which is useful during development when your editor already provides type feedback. The --swc flag uses the SWC transpiler (written in Rust) for an even greater speed improvement, and implies --transpileOnly. ESM mode (--esm) handles ES module imports and is needed when working with import/export syntax natively. The built-in REPL provides an interactive TypeScript environment for experimentation.Configuration is loaded from tsconfig.json by default, and a custom config can be specified with -P. The tool integrates well with development workflows using ts-node-dev or nodemon for automatic restart on file changes.
PARAMETERS
-P FILE
Path to tsconfig.json.--transpile-only, -T
Skip type checking.--esm
Use ESM loader.-e CODE
Evaluate code.-p CODE
Evaluate and print.-r MODULE
Require module.--pretty
Pretty-print errors.--skip-project
Skip loading tsconfig.json.--swc
Transpile with SWC for faster startup. Implies --transpileOnly.--files
Load files, include, and exclude from tsconfig.json on startup.-C NAME, --compiler NAME
TypeScript compiler to use (default: typescript).-D CODES, --ignoreDiagnostics CODES
Ignore TypeScript diagnostics by code.--emit
Write compiled output files to .ts-node directory.-i, --interactive
Force REPL even if stdin is not a terminal.--skipIgnore
Skip ignore checks, allowing compilation of files in node_modules.-O JSON, --compilerOptions JSON
Merge JSON compiler options with tsconfig.--showConfig
Print resolved tsconfig.json and exit.
CAVEATS
Slower startup than precompiled JavaScript. Type checking adds overhead. Some advanced TypeScript features need configuration. Not recommended for production.
HISTORY
ts-node was created around 2015 to enable direct TypeScript execution. It became essential for TypeScript development, enabling scripts, REPL, and development servers.
