Node TypeScript Compiler Wrapper

4.0.0 · active · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart compiles the current TypeScript project using the `tsconfig.json` located in the current directory.

import tsc from 'node-typescript-compiler';

async function compileProject() {
  try {
    console.log('Starting TypeScript compilation...');
    await tsc.compile({
      'project': '.' // Refers to tsconfig.json in the current directory
    });
    console.log('TypeScript compilation successful.');
  } catch (error) {
    console.error('TypeScript compilation failed:', error.message);
    process.exit(1);
  }
}

compileProject();

view raw JSON →