tsc-watch is a utility that wraps the TypeScript compiler's --watch mode and adds lifecycle hooks to execute commands on compilation events such as success, failure, or first success. It is commonly used as a drop-in replacement for nodemon in TypeScript projects to restart a Node.js server after successful recompilations. The current stable version is 7.2.0, with a release cadence of several minor versions per year. Key differentiators include built-in support for debounced file emission events, signal handling, and the ability to run arbitrary commands without needing an additional process manager. Unlike plain tsc --watch, tsc-watch provides fine-grained control over development workflows and integrates seamlessly with TypeScript's existing compiler options.
npm install tsc-watchVerified import paths — ran on the pinned version, not inferred.
Runs TypeScript compiler in watch mode and executes 'node dist/index.js' on every successful compilation, without clearing the terminal.
Use import or dynamic import in ES modules. For older Node versions, stick with v5.x.
Use --compileCommand instead.
Ensure your command handles SIGTERM properly or use a process manager like pm2.
Use --onSuccess for one-time actions after compilation, or add debouncing logic in your command.
Ensure typescript is installed and compatible. The peer dependency is '*' so any version should work, but test with your project.
Change import to import TscWatchClient from 'tsc-watch/client' (for ESM) or use dynamic import.
Run 'npm install --save-dev tsc-watch' then use npx tsc-watch or add a script in package.json.
Use import TscWatchClient from 'tsc-watch/client' and then new TscWatchClient(...).