Registry / devops / tsc-watch

tsc-watch

JSON →
library7.2.0jsnpmunverified

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-watch
INSTALL
IMPORT
SIG · TSC-WATCH
T
tsc-watch
devopsjavascriptv7.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tsc-watch (CLI)
npx tsc-watch --onSuccess "node dist/index.js"
tsc --watch --onSuccess "node dist/index.js"
tsc-watch is a CLI tool, not a library. It is invoked via npx or installed globally. The wrong pattern shows expecting tsc to support --onSuccess.
default (programmatic API)
import TscWatchClient from 'tsc-watch/client'
const TscWatchClient = require('tsc-watch').default
The programmatic API is exported as a default class from 'tsc-watch/client'. This module is ESM-only since v6.
TscWatchClient (type import)
import type TscWatchClient from 'tsc-watch/client'
import { TscWatchClient } from 'tsc-watch'
For TypeScript users, the type is exported only from 'tsc-watch/client'. Importing from the main package or as named will fail.

Runs TypeScript compiler in watch mode and executes 'node dist/index.js' on every successful compilation, without clearing the terminal.

npx tsc-watch --onSuccess "node dist/index.js" --noClear
tsc-watch --version
Debug
Known issues
breakingVersion 6.0.0 dropped CommonJS support; programmatic API is ESM-only. Requiring 'tsc-watch' with require() will fail.
fix
Use import or dynamic import in ES modules. For older Node versions, stick with v5.x.
affects: >=6.0.0
deprecatedThe --compiler option is deprecated and will be removed in a future version.
fix
Use --compileCommand instead.
affects: >=6.0.0
gotchaonSuccess command is killed with SIGTERM on process exit; if your command spawns child processes, they may not be cleaned up.
fix
Ensure your command handles SIGTERM properly or use a process manager like pm2.
affects: all
gotchaThe --onEmit event fires for each emitted file, so a single compilation may trigger multiple commands. This can cause race conditions if commands are not idempotent.
fix
Use --onSuccess for one-time actions after compilation, or add debouncing logic in your command.
affects: all
gotchatsc-watch requires a peer dependency of TypeScript; using a mismatched TypeScript version may cause unexpected behavior.
fix
Ensure typescript is installed and compatible. The peer dependency is '*' so any version should work, but test with your project.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'tsc-watch/client'
Attempting to require or import the programmatic API from the main package instead of 'tsc-watch/client'.
fix
Change import to import TscWatchClient from 'tsc-watch/client' (for ESM) or use dynamic import.
tsc-watch: command not found
tsc-watch is not installed globally or not in node_modules/.bin.
fix
Run 'npm install --save-dev tsc-watch' then use npx tsc-watch or add a script in package.json.
TypeError: tscWatchClient is not a constructor
Using the default import incorrectly, e.g., importing as named or using require incorrectly.
fix
Use import TscWatchClient from 'tsc-watch/client' and then new TscWatchClient(...).
Upgrade
Version history
7.2.0latest on npm
Audit
Dependencies
typescriptrequiredtsc-watch runs the TypeScript compiler (tsc) under the hood and requires it as a peer dependency.
cross-spawnrequiredUsed internally to spawn child processes with proper cross-platform signal handling.
ps-treerequiredUsed to kill child process trees on exit to clean up spawned commands.
string-argvrequiredParses command strings into arrays for safe spawning.
Agent activity
2 hits · last 30 days
node
2
Resources
tsc-watch — npm install tsc-watch · libregistry