{"id":25645,"library":"google-closure-compiler-linux","title":"Closure Compiler Linux Native Distribution","description":"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.","status":"active","version":"20260428.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/ChadKillingsworth/closure-compiler-npm","tags":["javascript","compiler","optimizer","minifier","closure","java"],"install":[{"cmd":"npm install google-closure-compiler-linux","lang":"bash","label":"npm"},{"cmd":"yarn add google-closure-compiler-linux","lang":"bash","label":"yarn"},{"cmd":"pnpm add google-closure-compiler-linux","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Users should install the main package which is the entry point; this Linux-specific package is an optional dependency of the main package.","package":"google-closure-compiler","optional":true}],"imports":[{"note":"Always use the main 'google-closure-compiler' package. The platform-specific package (this one) is an internal dependency and should never be imported directly.","wrong":"const compile = require('google-closure-compiler-linux').compile;","symbol":"compile","correct":"import { compile } from 'google-closure-compiler';"},{"note":"The binary is installed via the main package. Running 'npx google-closure-compiler' uses the correct platform-specific binary under the hood.","wrong":"npx google-closure-compiler-linux  # this command does not exist","symbol":"google-closure-compiler (binary)","correct":"npx google-closure-compiler  # or the binary path from node_modules/.bin/closure-compiler"},{"note":"The main package provides a getJarPath() helper to locate the native binary. Do not try to resolve the path from the platform-specific package directly.","wrong":"const jar = require('google-closure-compiler-linux').jar;","symbol":"compiler.jar","correct":"const { getJarPath } = require('google-closure-compiler'); const jar = getJarPath();"}],"quickstart":{"code":"// Install the main package (this Linux-specific package is an optional dependency and will be installed automatically on Linux)\nnpm install google-closure-compiler\n\n// Command-line usage: compile a JS file\nnpx google-closure-compiler --js input.js --js_output_file output.js --compilation_level ADVANCED\n\n// Programmatic usage in Node.js\nimport { compile } from 'google-closure-compiler';\n\nconst compiler = new compile({\n  js: './src/**/*.js',\n  compilation_level: 'ADVANCED',\n  js_output_file: './dist/bundle.js'\n});\n\ncompiler.run((exitCode, output) => {\n  if (exitCode === 0) {\n    console.log('Compilation successful.');\n  } else {\n    console.error('Compilation error:', output);\n  }\n});","lang":"javascript","description":"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."},"warnings":[{"fix":"Install 'google-closure-compiler' instead of 'google-closure-compiler-linux'.","message":"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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure optional dependencies are enabled during install, or install Java. Alternatively, use the flag --no-optional to force Java fallback explicitly.","message":"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.","severity":"breaking","affected_versions":">=20210406.0.0"},{"fix":"Update to latest version and use 'npx google-closure-compiler' as the command.","message":"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.","severity":"deprecated","affected_versions":"<20220000.0.0"},{"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.","message":"The compilation process requires significant memory (heap) for large codebases. Default heap may be insufficient, causing out-of-memory errors.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Refer to official Closure Compiler release notes before upgrading. Pin your version if using advanced optimizations.","message":"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.","severity":"breaking","affected_versions":">=20200000.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install the main package: npm install google-closure-compiler","cause":"Installed platform-specific package directly instead of main package. The Linux-specific package is not meant to be required.","error":"Error: Cannot find module 'google-closure-compiler-linux'"},{"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.","cause":"Optional dependencies not installed (e.g., npm install --no-optional) or platform binary missing (e.g., on a non-Linux OS).","error":"WARNING: failed to get platform binary, falling back to java version. Ensure Java is installed."},{"fix":"Increase heap: use NODE_OPTIONS=--max-old-space-size=8192 or add --jvm_flag=-Xmx8G to the compiler command.","cause":"Default Java heap is too small for the codebase being compiled.","error":"OutOfMemoryError: Java heap space"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}