Package Exports
- ts-node
- ts-node/dist/bin/ts-node
- ts-node/package.json
- ts-node/register
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ts-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
TypeScript Node
TypeScript execution environment and REPL for node. Works with
typescript@>=1.5
.
Installation
npm install -g ts-node
# Install a TypeScript compiler (requires `typescript` by default).
npm install -g typescript
Features
- Execute TypeScript files with node
- Interactive REPL
- Execute (and print) TypeScript through the CLI
- Uses source maps
- Loads from
tsconfig.json
Usage
# Execute a script as you world normally with `node`.
ts-node script.ts
# Starts the TypeScript REPL.
ts-node
# Execute code snippets with TypeScript.
ts-node -e 'console.log("Hello, world!")'
# Execute and print code snippets with TypeScript.
ts-node -p '"Hello, world!"'
Mocha:
mocha test.ts --require ts-node/register src/**/*.spec.ts
Tape:
ts-node node_modules/tape/bin/tape src/**/*.spec.ts
Loading tsconfig.json
Typescript Node automatically loads tsconfig.json
options and referenced files from the current directory using tsconfig.
Configuration Options
You can set options by passing them in before the script.
ts-node --compiler ntypescript --project src --ignoreWarnings 2304 hello-world.ts
- project Location to resolve
tsconfig.json
from. - compiler Use a custom, require-able TypeScript compiler compatible with
typescript@>=1.5.0-alpha
. - ignoreWarnings Set an array of TypeScript diagnostic codes to ignore.
- disableWarnings Ignore all TypeScript errors.
Programmatic Usage
require('ts-node').register({ /* options */ })
// Or using the shortcut file.
require('ts-node/register')
License
MIT