{"id":26001,"library":"node-latex-compiler","title":"node-latex-compiler","description":"Node.js LaTeX compiler wrapper using Tectonic engine with automatic binary download. Current stable version 1.0.5, actively maintained. Key differentiators: zero system dependencies, cross-platform binary auto-detection (Windows, macOS Intel/ARM, Linux), automatic CTAN package management, multiple I/O formats (file, text, buffer), real-time stdout/stderr streaming, and full TypeScript definitions. Unlike traditional LaTeX distributions (MiKTeX, TeX Live) or other Node wrappers (node-latex, latex-js), this package requires no manual installation of LaTeX binaries and handles platform-specific binaries automatically.","status":"active","version":"1.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/JaredYe04/node-latex-compiler","tags":["javascript","latex","tectonic","tex","pdf","compiler","latex-compiler","document-compiler","typescript"],"install":[{"cmd":"npm install node-latex-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add node-latex-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-latex-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is not available; only named export. CommonJS users must use destructuring require. This is an ESM-first package but supports both ESM and CJS.","wrong":"const compile = require('node-latex-compiler')","symbol":"compile","correct":"import { compile } from 'node-latex-compiler'"},{"note":"For CommonJS, destructure from require. Using .default will result in undefined.","wrong":"const compile = require('node-latex-compiler').default","symbol":"compile","correct":"const { compile } = require('node-latex-compiler')"},{"note":"TypeScript types for config and result are auto-generated and available as named exports. Use type imports for runtime-free type usage.","symbol":"compile type","correct":"import type { CompileConfig, CompileResult } from 'node-latex-compiler'"}],"quickstart":{"code":"import { compile } from 'node-latex-compiler';\n\nconst tex = `\\\\documentclass{article}\n\\\\usepackage{amsmath}\n\\\\begin{document}\nHello, World! This is a test document.\n\n\\\\[\nE = mc^2\n\\\\]\n\\\\end{document}`;\n\nasync function main() {\n  const result = await compile({\n    tex: tex,\n    outputDir: './output',\n    returnBuffer: true,\n    onStdout: (data) => process.stdout.write(`[stdout] ${data}`),\n    onStderr: (data) => process.stderr.write(`[stderr] ${data}`),\n  });\n\n  if (result.status === 'success') {\n    const fs = await import('fs');\n    fs.writeFileSync('./output.pdf', result.pdfBuffer);\n    console.log('PDF generated as buffer');\n  } else {\n    console.error('Compilation failed:', result.stderr);\n  }\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Compiles a LaTeX string to PDF buffer with real-time stdout/stderr streaming and writes the output file."},"warnings":[{"fix":"Pre-download the binary for your platform and set the TECTONIC_BIN environment variable to its path before running compile.","message":"Automatic binary download occurs during npm install, which may fail in restricted environments (corporate proxies, CI with no outbound access).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always check result.status first, then access result.pdfPath (file output) or result.pdfBuffer (buffer output) accordingly.","message":"The compile function returns different result shapes depending on whether returnBuffer is true or false. Ensure you check the correct property (pdfPath vs pdfBuffer).","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Pass exactly one of tex or texFile. Do not pass both.","message":"The texFile and tex parameters are mutually exclusive but no runtime validation is performed; passing both will cause undefined behavior.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Install libfontconfig1 on Debian/Ubuntu: sudo apt-get install libfontconfig1","message":"On Linux, the auto-downloaded binary may require libfontconfig1 to be installed. Missing this library causes silent failure.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If you need a custom binary, consider forking the package or pre-placing your binary at the expected location.","message":"The package does not support custom binary paths via environment variable (e.g., TECTONIC_BIN). You must use the auto-downloaded binary.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Reinstall: rm -rf node_modules && npm install node-latex-compiler","cause":"Package not installed or failed to install (binary download may have failed).","error":"Error: Cannot find module 'node-latex-compiler'"},{"fix":"Reinstall the package or manually set executable permissions: chmod +x node_modules/node-latex-compiler/bin/tectonic-*","cause":"The downloaded binary is missing, corrupted, or lacks execute permissions.","error":"Error: spawn /path/to/tectonic ENOENT"},{"fix":"Use correct import: import { compile } from 'node-latex-compiler' (ESM) or const { compile } = require('node-latex-compiler') (CJS).","cause":"Incorrect import: importing default instead of named export, or using require without destructuring.","error":"TypeError: compile is not a function"},{"fix":"Provide only one of tex (string content) or texFile (file path).","cause":"Passing both tex and texFile parameters to compile().","error":"Error: tex and texFile are mutually exclusive"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}