Skip to main content

Options

ts-node supports --print (-p), --eval (-e), --require (-r) and --interactive (-i) similar to the node.js CLI options.

Environment variables, where available, are in ALL_CAPS

Shell#

  • -h, --help Prints the help text
  • -v, --version Prints the version. -vv prints node and typescript compiler versions, too
  • -e, --eval Evaluate code
  • -p, --print Print result of --eval
  • -i, --interactive Opens the REPL even if stdin does not appear to be a terminal

TSConfig#

  • -P, --project [path] Path to TypeScript JSON project file
    Environment: TS_NODE_PROJECT
  • --skip-project Skip project config resolution and loading
    Default: false
    Environment: TS_NODE_SKIP_PROJECT
  • -c, --cwd-mode Resolve config relative to the current directory instead of the directory of the entrypoint script
  • -O, --compiler-options [opts] JSON object to merge with compiler options
    Environment: TS_NODE_COMPILER_OPTIONS
  • --show-config Print resolved tsconfig.json, including ts-node options, and exit

Typechecking#

  • -T, --transpile-only Use TypeScript's faster transpileModule
    Default: false
    Environment: TS_NODE_TRANSPILE_ONLY
  • --type-check Opposite of --transpile-only
    Default: true
    Environment: TS_NODE_TYPE_CHECK
  • -H, --compiler-host Use TypeScript's compiler host API
    Default: false
    Environment: TS_NODE_COMPILER_HOST
  • --files Load files, include and exclude from tsconfig.json on startup
    Default: false
    Environment: TS_NODE_FILES
  • -D, --ignore-diagnostics [code] Ignore TypeScript warnings by diagnostic code
    Environment: TS_NODE_IGNORE_DIAGNOSTICS

Transpilation#

  • -I, --ignore [pattern] Override the path patterns to skip compilation
    Default: /node_modules/
    Environment: TS_NODE_IGNORE
  • --skip-ignore Skip ignore checks
    Default: false
    Environment: TS_NODE_SKIP_IGNORE
  • -C, --compiler [name] Specify a custom TypeScript compiler
    Default: typescript
    Environment: TS_NODE_COMPILER
  • --transpiler [name] Specify a third-party, non-typechecking transpiler
  • --prefer-ts-exts Re-order file extensions so that TypeScript imports are preferred
    Default: false
    Environment: TS_NODE_PREFER_TS_EXTS

Diagnostics#

  • --log-error Logs TypeScript errors to stderr instead of throwing exceptions
    Default: false
    Environment: TS_NODE_LOG_ERROR
  • --pretty Use pretty diagnostic formatter
    Default: false
    Environment: TS_NODE_PRETTY
  • TS_NODE_DEBUG Enable debug logging

Advanced#

  • -r, --require [path] Require a node module before execution
  • --cwd Behave as if invoked in this working directory
    Default: process.cwd()
    Environment: TS_NODE_CWD
  • --emit Emit output files into .ts-node directory
    Default: false
    Environment: TS_NODE_EMIT
  • --scope Scope compiler to files within scopeDir. Anything outside this directory is ignored.
    Default: false
    Environment:* TS_NODE_SCOPE
  • --scopeDir Directory within which compiler is limited when scope is enabled.
    Default: First of: tsconfig.json "rootDir" if specified, directory containing tsconfig.json, or cwd if no tsconfig.json is loaded.
    Environment: TS_NODE_SCOPE_DIR
  • moduleType Override the module type of certain files, ignoring the package.json "type" field. See Module type overrides for details.
    Default: obeys package.json "type" and tsconfig.json "module"
    Can only be specified via tsconfig.json or API.
  • TS_NODE_HISTORY Path to history file for REPL
    Default: ~/.ts_node_repl_history

API#

The API includes additional options not shown here.