{"id":12771,"library":"node-typescript-compiler","title":"Node TypeScript Compiler Wrapper","description":"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.","status":"active","version":"4.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/Offirmo/offirmo-monorepo--2022#main","tags":["javascript","hello","typescript"],"install":[{"cmd":"npm install node-typescript-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add node-typescript-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-typescript-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as a sibling dev dependency for `tsc` functionality.","package":"typescript","optional":false}],"imports":[{"note":"Since v4, this package is pure ESM, requiring Node.js >= 12. The default export is an object that contains the main `compile` function.","wrong":"const tsc = require('node-typescript-compiler');","symbol":"tsc","correct":"import tsc from 'node-typescript-compiler';"},{"note":"The `compile` function is a method accessed via the default-exported `tsc` object, not a direct named export. Attempting to destructure it will fail.","wrong":"import { compile } from 'node-typescript-compiler';","symbol":"compile","correct":"import tsc from 'node-typescript-compiler'; await tsc.compile(...);"},{"note":"CommonJS `require()` is not supported in version 4.0.0 and later. Ensure your project is configured for ESM or use an older major version (e.g., v3).","wrong":"const myCompiler = require('node-typescript-compiler');","symbol":"CommonJS usage","correct":null}],"quickstart":{"code":"import tsc from 'node-typescript-compiler';\n\nasync function compileProject() {\n  try {\n    console.log('Starting TypeScript compilation...');\n    await tsc.compile({\n      'project': '.' // Refers to tsconfig.json in the current directory\n    });\n    console.log('TypeScript compilation successful.');\n  } catch (error) {\n    console.error('TypeScript compilation failed:', error.message);\n    process.exit(1);\n  }\n}\n\ncompileProject();","lang":"javascript","description":"This quickstart compiles the current TypeScript project using the `tsconfig.json` located in the current directory."},"warnings":[{"fix":"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.","message":"Version 4.0.0 and later of `node-typescript-compiler` are pure ESM (ECMAScript Modules) only. CommonJS `require()` is no longer supported.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Upgrade your Node.js runtime to version 12 or newer. For older Node.js versions, use `node-typescript-compiler@3`.","message":"`node-typescript-compiler` now requires Node.js version 12 or higher due to its transition to pure ESM.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Install `typescript` alongside `node-typescript-compiler`: `npm i --save-dev typescript node-typescript-compiler`.","message":"The `typescript` package is a peer dependency and must be installed separately as a sibling `devDependency`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"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.","message":"It is strongly recommended to have a working TypeScript setup (with `tsc` and `tsconfig.json`) configured before using `node-typescript-compiler`.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2023':81 '4.0.0':68 'act':136 'advanc':47 'allow':35 'around':93 'badg':79 'build':48 'cadenc':73 'catch':99 'child':32 'clear':126 'cli':96 'command':27 'command-lin':26 'compil':3,8,20,52,61,102,135 'concern':129 'control':115 'current':64 'depend':111 'design':123 'develop':36 'differ':60 'differenti':87 'e.g':57 'enabl':46 'ensur':130 'error':103 'explicit':114 'expos':14 'formal':71 'function':16 'give':112 'hello':147 'indic':82 'invok':39 'javascript':146 'key':86 'line':28 'mainten':78 'modul':12,56 'multipl':53 'node':1,6,133 'node-typescript-compil':5,132 'node.js':11,44 'node/browser':58 'ongo':83 'option':62 'orchestr':140 'peer':110 'primarili':137 'process':33 'programmat':38 'promot':124 'proper':98 'releas':72 'reliabl':91 'report':101 'script':45 'separ':127 'simpl':90 'spawn':23 'specifi':76 'stabl':65 'standard':143 'support':84 'tool':29 'toolchain':145 'treat':105 'tsc':21,25,40,95,118 'typescript':2,7,19,106,134,144,148 'use':121 'user':113 'variant':54 'version':66,119 'within':42 'workflow':49 'wrapper':4,92","created_at":"2026-04-19T16:53:21.909002+00:00","updated_at":"2026-04-19T16:53:21.909002+00:00","problems":[{"fix":"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.","cause":"Attempting to use CommonJS `require()` to import `node-typescript-compiler` v4.x.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported."},{"fix":"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`.","cause":"The underlying `tsc` command invoked by `node-typescript-compiler` failed, likely due to compilation errors, a misconfigured `tsconfig.json`, or `tsc` not being found.","error":"Error: Command failed with exit code 1"},{"fix":"Verify you are using `import tsc from 'node-typescript-compiler';` and that the package is correctly installed in your `node_modules`.","cause":"The `node-typescript-compiler` module was not imported correctly, or the imported `tsc` object does not contain the `compile` method, possibly due to a version mismatch or incorrect import syntax.","error":"TypeError: tsc.compile is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Offirmo/offirmo-monorepo--2022.git#main","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/node-typescript-compiler","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}