Closure Compiler Linux Native Distribution
raw JSON →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.
Common errors
error Error: Cannot find module 'google-closure-compiler-linux' ↓
error WARNING: failed to get platform binary, falling back to java version. Ensure Java is installed. ↓
error OutOfMemoryError: Java heap space ↓
Warnings
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. ↓
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. ↓
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. ↓
gotcha The compilation process requires significant memory (heap) for large codebases. Default heap may be insufficient, causing out-of-memory errors. ↓
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. ↓
Install
npm install google-closure-compiler-linux yarn add google-closure-compiler-linux pnpm add google-closure-compiler-linux Imports
- compile wrong
const compile = require('google-closure-compiler-linux').compile;correctimport { compile } from 'google-closure-compiler'; - google-closure-compiler (binary) wrong
npx google-closure-compiler-linux # this command does not existcorrectnpx google-closure-compiler # or the binary path from node_modules/.bin/closure-compiler - compiler.jar wrong
const jar = require('google-closure-compiler-linux').jar;correctconst { getJarPath } = require('google-closure-compiler'); const jar = getJarPath();
Quickstart
// 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);
}
});