Socket
Socket
Sign inDemoInstall

ts-node

Package Overview
Dependencies
31
Maintainers
1
Versions
128
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ts-node

TypeScript execution environment for node


Version published
Weekly downloads
18M
decreased by-21.35%
Maintainers
1
Install size
0.972 MB
Created
Weekly downloads
 

Package description

What is ts-node?

The ts-node npm package is a TypeScript execution engine and REPL for Node.js. It allows developers to run TypeScript files directly without precompiling them to JavaScript. This is particularly useful for development purposes where you can execute scripts or run a REPL environment without an additional build step.

What are ts-node's main functionalities?

Execute TypeScript files

Run a TypeScript file directly from the command line without prior compilation.

ts-node script.ts

REPL

Start a TypeScript REPL (Read-Eval-Print Loop) to execute TypeScript code interactively.

ts-node

Transpile Only Mode

Run TypeScript files without type checking for faster execution, suitable for development.

ts-node --transpile-only script.ts

Type Checking

Enable type checking when running a TypeScript file, ensuring that the code adheres to the defined types.

ts-node --type-check script.ts

Integration with Testing Frameworks

Use ts-node to run TypeScript tests with Mocha or other Node.js testing frameworks.

mocha --require ts-node/register tests/**/*.spec.ts

Other packages similar to ts-node

Readme

Source

TypeScript Node

NPM version NPM downloads Build status Test coverage

TypeScript execution environment 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

TypeScript REPL

  • Execute TypeScript files with node
  • Interactive REPL
  • Execute (and print) TypeScript through the CLI
  • Supports source maps
  • Supports tsconfig.json

Usage

# Execute a script as you world normally with `node`.
ts-node script.ts

# Start 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 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

Keywords

FAQs

Last updated on 22 Sep 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc