node-tsc

raw JSON →
0.0.14 verified Fri May 01 auth: no javascript deprecated

node-tsc wraps the TypeScript command-line compiler (tsc) as a Node.js module, enabling programmatic compilation of TypeScript files. Version 0.0.14 is the latest stable release, last updated in 2015. It provides a simple API to compile TypeScript code without invoking the CLI. Notable issues: the package is unmaintained, very outdated, and does not support modern TypeScript features (ES modules, strict mode). Dependencies are minimal: only Node.js and a TypeScript compiler from npm (installed separately). Key differentiator: simple wrapper for tsc, but now obsolete; use ts-node, @ts-morph/bootstrap, or the official TypeScript API instead.

error Error: Cannot find module 'typescript'
cause node-tsc requires typescript to be installed, but it is not a dependency.
fix
Run 'npm install typescript'.
error TypeError: tsc.compile(...) is not a function
cause Incorrect import: trying to use default import instead of require.
fix
Use 'const tsc = require('node-tsc');' instead of 'import tsc from 'node-tsc';'.
deprecated Package is unmaintained and outdated; use official TypeScript API instead.
fix Replace with ts-node, @ts-morph/bootstrap, or TypeScript's compiler API directly.
gotcha The package does not install TypeScript as a dependency; you must install typescript separately.
fix Run 'npm install typescript' in your project.
gotcha Options are passed directly to tsc; some options may not work as expected due to old version compatibility.
fix Test with your TypeScript version; consider using official API for better compatibility.
gotcha No support for TypeScript project references or incremental compilation.
fix Use official TypeScript API or tools like ts-project-utils.
npm install node-tsc
yarn add node-tsc
pnpm add node-tsc

Shows programmatic TypeScript compilation using compile() with callback.

const tsc = require('node-tsc');
const options = {
  outDir: 'dist',
  module: 'commonjs',
  target: 'es5',
  sourceMap: true
};
tsc.compile(['src/index.ts'], options, function(err, output) {
  if (err) {
    console.error('Compilation error:', err);
  } else {
    console.log('Compilation succeeded');
    console.log('Output files:', output);
  }
});