node-typescript-compiler is a Node.js module that exposes the functionality of the TypeScript compiler (tsc) by spawning the tsc command-line tool as a child process. This allows developers to programmatically invoke tsc from within a Node.js script, enabling advanced build workflows such as compiling multiple variants of modules (e.g., Node/browser) with different compiler options. The current stable version is 4.0.0. While a formal release cadence is not specified, a maintenance badge from 2023 indicates ongoing support. A key differentiator is its simple, reliable wrapper around the tsc CLI, which properly catches and reports compilation errors. It treats `typescript` itself as a peer dependency, giving users explicit control over which tsc version is used. This design promotes a clear separation of concerns, ensuring that node-typescript-compiler acts primarily as an orchestrator for the standard TypeScript toolchain.
npm install node-typescript-compilerVerified import paths — ran on the pinned version, not inferred.
This quickstart compiles the current TypeScript project using the `tsconfig.json` located in the current directory.
Update your project to use ESM `import` statements and ensure your Node.js environment is configured for ESM (e.g., by setting `"type": "module"` in `package.json`). Node.js version 12 or higher is required.
Upgrade your Node.js runtime to version 12 or newer. For older Node.js versions, use `node-typescript-compiler@3`.
Install `typescript` alongside `node-typescript-compiler`: `npm i --save-dev typescript node-typescript-compiler`.
Verify your `tsconfig.json` and source files compile correctly by running `tsc --project .` directly in your terminal before integrating `node-typescript-compiler` into your build script.
Migrate your project to ESM and use `import tsc from 'node-typescript-compiler';`, ensuring your `package.json` includes `"type": "module"` or files use `.mjs` extension. Alternatively, downgrade to `node-typescript-compiler@3` for CJS support.
Ensure the `typescript` package is installed (`npm i --save-dev typescript`). Check your `tsconfig.json` for errors, or verify your source files compile correctly by running `tsc --project .` directly. Enable verbose output in `node-typescript-compiler` options (`verbose: true`) for more detailed error messages from `tsc`.
Verify you are using `import tsc from 'node-typescript-compiler';` and that the package is correctly installed in your `node_modules`.