Closure Compiler Linux Native Distribution

raw JSON →
20260428.0.0 verified Fri May 01 auth: no javascript

Linux native binary distribution of Google Closure Compiler, version 20260428.0.0 (published Apr 2025, with weekly releases). This package provides the Java-based Closure Compiler as a precompiled Linux binary, enabling JavaScript/TypeScript compilation, optimization, and minification without a local Java runtime dependency. It is one of several platform-specific packages (linux, macos, windows) under the google-closure-compiler umbrella, automatically selected by the main package. Key differentiators: true native performance, no Java required, auto-selection via optionalDependencies, and support for advanced compilation (type checking, dead code elimination, inline functions). Alternative toolchains include esbuild and Terser, but Closure Compiler offers deeper optimization at the cost of slower execution.

error Error: Cannot find module 'google-closure-compiler-linux'
cause Installed platform-specific package directly instead of main package. The Linux-specific package is not meant to be required.
fix
Install the main package: npm install google-closure-compiler
error WARNING: failed to get platform binary, falling back to java version. Ensure Java is installed.
cause Optional dependencies not installed (e.g., npm install --no-optional) or platform binary missing (e.g., on a non-Linux OS).
fix
Either enable optional dependencies (remove --no-optional) or install Java. On non-Linux systems, install the appropriate platform package: google-closure-compiler-macos or google-closure-compiler-windows.
error OutOfMemoryError: Java heap space
cause Default Java heap is too small for the codebase being compiled.
fix
Increase heap: use NODE_OPTIONS=--max-old-space-size=8192 or add --jvm_flag=-Xmx8G to the compiler command.
gotcha This package is platform-specific and should never be installed directly. Always install the main 'google-closure-compiler' package, which will automatically install the correct platform binary via optionalDependencies.
fix Install 'google-closure-compiler' instead of 'google-closure-compiler-linux'.
breaking The native binary may not be installed if npm/yarn optionalDependencies are disabled (e.g., --no-optional). In that case, the main package falls back to a Java-based version, which requires a JDK.
fix Ensure optional dependencies are enabled during install, or install Java. Alternatively, use the flag --no-optional to force Java fallback explicitly.
deprecated Older versions used a different binary naming scheme. The current package (v20260428.0.0) uses the 'closure-compiler' binary; earlier versions might have used 'cc' or other names.
fix Update to latest version and use 'npx google-closure-compiler' as the command.
gotcha The compilation process requires significant memory (heap) for large codebases. Default heap may be insufficient, causing out-of-memory errors.
fix Set environment variable NODE_OPTIONS=--max-old-space-size=4096 or use the CLI flag --java --jvm_flag=-Xmx4G if using the Java version.
breaking Breaking changes between Closure Compiler versions: specific compiler flags or optimization behaviors may change. Each release (weekly) may introduce breaking changes in advanced compilation modes.
fix Refer to official Closure Compiler release notes before upgrading. Pin your version if using advanced optimizations.
npm install google-closure-compiler-linux
yarn add google-closure-compiler-linux
pnpm add google-closure-compiler-linux

Shows both CLI and programmatic usage of Closure Compiler on Linux, including npm install, basic CLI command, and Node.js API with the compile class.

// Install the main package (this Linux-specific package is an optional dependency and will be installed automatically on Linux)
npm install google-closure-compiler

// Command-line usage: compile a JS file
npx google-closure-compiler --js input.js --js_output_file output.js --compilation_level ADVANCED

// Programmatic usage in Node.js
import { compile } from 'google-closure-compiler';

const compiler = new compile({
  js: './src/**/*.js',
  compilation_level: 'ADVANCED',
  js_output_file: './dist/bundle.js'
});

compiler.run((exitCode, output) => {
  if (exitCode === 0) {
    console.log('Compilation successful.');
  } else {
    console.error('Compilation error:', output);
  }
});