ts-node-dev
Compiles your TS app and restarts when files are modified.
Last updated 4 days ago by whitecolor .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ts-node-dev -g
SYNC missed versions from official npm registry.

ts-node-dev

Tweaked version of node-dev that uses ts-node under the hood.

It restarts target node process when any of required files changes (as standard node-dev) but shares Typescript compilation process between restarts. This significantly increases speed of restarting comparing to node-dev -r ts-node/register ..., nodemon -x ts-node ... variations because there is no need to instantiate ts-node compilation each time.

Install

npm (scoped) Build Status

yarn add ts-node-dev --dev
npm i ts-node-dev --save-dev

ts-node dependency version is not fixed, so it will install the latest version by default.

Usage

ts-node-dev [node-dev|ts-node flags] [ts-node-dev flags] [node cli flags] [--] [script] [script arguments]

So you just combine node-dev and ts-node options (see docs of those packages):

ts-node-dev --respawn --transpile-only server.ts

There is also short alias tsnd for running ts-node-dev:

tsnd --respawn server.ts

Also there are additional options specific to ts-node-dev:

  • --prefer-ts (--prefer-ts-exts) - (default: false) - For each .js file (that is not in node_modules) will try to check if corresponding .ts version exists and require it.

  • --ignore-watch - (default: []) - files/folders to be ignored by node-dev. But also this behaviour enhanced: it will also make up new RegExp of passed ignore string and check absolute paths of required files for match. So, to ignore everything in node_modules, just pass --ignore-watch node_modules, or us --no-deps for the same effect.

  • --debug - Some additional debug output.

  • --interval - Polling interval (ms)

  • --debounce - Debounce file change events (ms, non-polling mode)

  • --clear (--cls) Will clear screen on restart

  • --watch - Explicitly add arbitrary files or folders to watch and restart on change (list separated by commas, chokidar patterns)

  • --exit-child - Adds 'SIGTERM' exit handler in a child process.

  • --rs - Allow to restart with "rs" line entered in stdio, disabled by default.

Caveats and points of notice:

  • Especially for large code bases always consider running with --transpile-only flag which is normal for dev workflow and will speed up things greatly. Note, that ts-node-dev will not put watch handlers on TS files that contain only types/interfaces (used only for type checking) - this is current limitation by design.

  • --ignore-watch will NOT affect files ignored by TS compilation. Use --ignore option (or TS_NODE_IGNORE env variable) to pass RegExp strings for filtering files that should not be compiled, by default /node_modules/ are ignored.

  • Unknown flags (node cli flags are considered to be so) are treated like string value flags by default. The right solution to avoid ambiguity is to separate script name from option flags with --, for example:

    ts-node-dev --inspect -- my-script.ts
    
  • The good thing is that ts-node-dev watches used tsconfig.json file, and will reinitialize compilation on its change, but you have to restart the process manually when you update used version of typescript or make any other changes that may effect compilation results.

Support

Support the project with a donation and help us to give it back. [Become a backer]

License

WTF.

Current Tags

  • 1.0.0-pre.51                                ...           latest (4 days ago)

51 Versions

  • 1.0.0-pre.51                                ...           4 days ago
  • 1.0.0-pre.50                                ...           12 days ago
  • 1.0.0-pre.49                                ...           a month ago
  • 1.0.0-pre.48                                ...           a month ago
  • 1.0.0-pre.47                                ...           a month ago
  • 1.0.0-pre.46                                ...           a month ago
  • 1.0.0-pre.45                                ...           a month ago
  • 1.0.0-pre.44                                ...           8 months ago
  • 1.0.0-pre.43                                ...           10 months ago
  • 1.0.0-pre.42                                ...           a year ago
  • 1.0.0-pre.41                                ...           a year ago
  • 1.0.0-pre.40                                ...           a year ago
  • 1.0.0-pre.39                                ...           a year ago
  • 1.0.0-pre.38                                ...           a year ago
  • 1.0.0-pre.37                                ...           a year ago
  • 1.0.0-pre.36                                ...           a year ago
  • 1.0.0-pre.35                                ...           a year ago
  • 1.0.0-pre.34                                ...           a year ago
  • 1.0.0-pre.33                                ...           a year ago
  • 1.0.0-pre.32                                ...           2 years ago
  • 1.0.0-pre.31                                ...           2 years ago
  • 1.0.0-pre.30                                ...           2 years ago
  • 1.0.0-pre.29                                ...           2 years ago
  • 1.0.0-pre.28                                ...           2 years ago
  • 1.0.0-pre.27                                ...           2 years ago
  • 1.0.0-pre.26                                ...           2 years ago
  • 1.0.0-pre.25                                ...           2 years ago
  • 1.0.0-pre.24                                ...           2 years ago
  • 1.0.0-pre.23                                ...           2 years ago
  • 1.0.0-pre.22                                ...           2 years ago
  • 1.0.0-pre.21                                ...           2 years ago
  • 1.0.0-pre.20                                ...           2 years ago
  • 1.0.0-pre.19                                ...           2 years ago
  • 1.0.0-pre.18                                ...           2 years ago
  • 1.0.0-pre.17                                ...           2 years ago
  • 1.0.0-pre.16                                ...           2 years ago
  • 1.0.0-pre.15                                ...           2 years ago
  • 1.0.0-pre.14                                ...           2 years ago
  • 1.0.0-pre.13                                ...           2 years ago
  • 1.0.0-pre.12                                ...           2 years ago
  • 1.0.0-pre.11                                ...           2 years ago
  • 1.0.0-pre.10                                ...           2 years ago
  • 1.0.0-pre.9                                ...           2 years ago
  • 1.0.0-pre.8                                ...           2 years ago
  • 1.0.0-pre.7                                ...           3 years ago
  • 1.0.0-pre.5                                ...           3 years ago
  • 1.0.0-pre.4                                ...           3 years ago
  • 1.0.0-pre.3                                ...           3 years ago
  • 1.0.0-pre.2                                ...           3 years ago
  • 1.0.0-pre.1                                ...           3 years ago
  • 1.0.0-pre.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 107
This Week 107
This Month 1,783
Last Day 45
Last Week 986
Last Month 3,978
Dependencies (12)
Dev Dependencies (18)
Dependents (169)

Copyright 2014 - 2016 © taobao.org |