| title | Options |
|---|
All command-line flags support both --camelCase and --hyphen-case.
Most options can be declared in your tsconfig.json: Configuration via tsconfig.json
ts-node supports --print (-p), --eval (-e), --require (-r) and --interactive (-i) similar to the node.js CLI.
ts-node supports --project and --showConfig similar to the tsc CLI.
Environment variables, where available, are in ALL_CAPS
ts-node --helpPrints the help text
ts-node -v
ts-node -vvvPrints the version. -vv includes node and typescript compiler versions. -vvv includes absolute paths to ts-node and
typescript installations.
ts-node -e <typescript code>
# Example
ts-node -e 'console.log("Hello world!")'Evaluate code
ts-node -p -e <typescript code>
# Example
ts-node -p -e '"Hello world!"'Print result of --eval
ts-node -iOpens the REPL even if stdin does not appear to be a terminal
ts-node --esm
ts-node-esmBootstrap with the ESM loader, enabling full ESM support
ts-node -P <path/to/tsconfig>
ts-node --project <path/to/tsconfig>Path to tsconfig file.
Note the uppercase -P. This is different from tsc's -p/--project option.
Environment: TS_NODE_PROJECT
ts-node --skipProjectSkip project config resolution and loading
Default: false
Environment: TS_NODE_SKIP_PROJECT
ts-node -c
ts-node --cwdMode
ts-node-cwdResolve config relative to the current directory instead of the directory of the entrypoint script
ts-node -O <json compilerOptions>
ts-node --compilerOptions <json compilerOptions>JSON object to merge with compiler options
Environment: TS_NODE_COMPILER_OPTIONS
ts-node --showConfigPrint resolved tsconfig.json, including ts-node options, and exit
ts-node -T
ts-node --transpileOnlyUse TypeScript's faster transpileModule
Default: false
Environment: TS_NODE_TRANSPILE_ONLY
ts-node --typeCheckOpposite of --transpileOnly
Default: true
Environment: TS_NODE_TYPE_CHECK
ts-node -H
ts-node --compilerHostUse TypeScript's compiler host API
Default: false
Environment: TS_NODE_COMPILER_HOST
ts-node --filesLoad files, include and exclude from tsconfig.json on startup. This may
avoid certain typechecking failures. See Missing types for details.
Default: false
Environment: TS_NODE_FILES
ts-node -D <code,code>
ts-node --ignoreDiagnostics <code,code>Ignore TypeScript warnings by diagnostic code
Environment: TS_NODE_IGNORE_DIAGNOSTICS
ts-node -I <regexp matching ignored files>
ts-node --ignore <regexp matching ignored files>Override the path patterns to skip compilation
Default: /node_modules/
Environment: TS_NODE_IGNORE
ts-node --skipIgnoreSkip ignore checks
Default: false
Environment: TS_NODE_SKIP_IGNORE
ts-node -C <name>
ts-node --compiler <name>Specify a custom TypeScript compiler
Default: typescript
Environment: TS_NODE_COMPILER
ts-node --swcTranspile with swc. Implies --transpileOnly
Default: false
ts-node --transpiler <name>
# Example
ts-node --transpiler ts-node/transpilers/swcUse a third-party, non-typechecking transpiler
ts-node --preferTsExtsRe-order file extensions so that TypeScript imports are preferred
Default: false
Environment: TS_NODE_PREFER_TS_EXTS
ts-node --logErrorLogs TypeScript errors to stderr instead of throwing exceptions
Default: false
Environment: TS_NODE_LOG_ERROR
ts-node --prettyUse pretty diagnostic formatter
Default: false
Environment: TS_NODE_PRETTY
TS_NODE_DEBUG=true ts-nodeEnable debug logging
ts-node -r <module name or path>
ts-node --require <module name or path>Require a node module before execution
ts-node --cwd <path/to/directory>Behave as if invoked in this working directory
Default: process.cwd()
Environment: TS_NODE_CWD
ts-node --emitEmit output files into .ts-node directory. Requires --compilerHost
Default: false
Environment: TS_NODE_EMIT
ts-node --scopeScope compiler to files within scopeDir. Anything outside this directory is ignored.
Default: false
Environment: TS_NODE_SCOPE
ts-node --scopeDir <path/to/directory>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
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> ts-nodePath to history file for REPL
Default: ~/.ts_node_repl_history
ts-node --noExperimentalReplAwaitDisable top-level await in REPL. Equivalent to node's --no-experimental-repl-await
Default: Enabled if TypeScript version is 3.8 or higher and target is ES2018 or higher.
Environment: TS_NODE_EXPERIMENTAL_REPL_AWAIT set false to disable
Enable experimental hooks that re-map imports and require calls to support:
- remapping extensions, e.g. so that
import "./foo.js"will executefoo.ts. Currently the following extensions will be mapped:.jsto.ts,.tsx, or.jsx.cjsto.cts.mjsto.mts.jsxto.tsx
- including file extensions in CommonJS, for consistency with ESM where this is often mandatory
In the future, this hook will also support:
baseUrl,pathsrootDirsoutDirtorootDirmappings for composite projects and monorepos
For details, see #1514.
Default: false, but will likely be enabled by default in a future version
Can only be specified via tsconfig.json or API.
ts-node --experimentalSpecifierResolution nodeLike node's --experimental-specifier-resolution, but can also be set in your tsconfig.json for convenience.
Requires esm to be enabled.
Default: explicit
The API includes additional options not shown here.