Closure Compiler - Windows Native

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

Native Windows platform distribution of Google Closure Compiler, providing the Windows executable (closure-compiler.exe) for JavaScript compilation, optimization, and minification. Current stable version is 20260428.0.0, released daily from the Closure Compiler repository. This package is specific to Windows (x64) and is one of multiple platform-specific distributions (also macOS, Linux). It is intended to be installed automatically as a dependency of the main google-closure-compiler package, which selects the correct platform package. Key differentiators: uses the native Java-free binary for Windows, no JVM required, CLI-only.

error Cannot find module 'google-closure-compiler-windows'
cause You are trying to require this package directly, but it is not the main entry point.
fix
Install and require 'google-closure-compiler' instead.
error Error: jarfile not found
cause You are trying to run the Java-based version of Closure Compiler, but the Windows native package is meant to be used with the native binary.
fix
Ensure you have installed google-closure-compiler and not google-closure-compiler-java.
error The term 'closure-compiler' is not recognized
cause The CLI command is not in PATH.
fix
Add node_modules/.bin to PATH or use npx google-closure-compiler.
gotcha This package only provides the Windows binary. It must be used via the main google-closure-compiler package, not directly.
fix Install google-closure-compiler instead. This package is automatically installed as a dependency.
gotcha The Windows binary requires Windows 64-bit. It will not work on 32-bit Windows or other OS.
fix For macOS, use google-closure-compiler-darwin. For Linux, use google-closure-compiler-linux.
deprecated Version numbers mirror Closure Compiler releases (e.g., 20260428). Breaking changes may occur without major version bump.
fix Pin to a specific version and test when upgrading.
npm install google-closure-compiler-windows
yarn add google-closure-compiler-windows
pnpm add google-closure-compiler-windows

Minify a JavaScript file using the main google-closure-compiler package with ADVANCED_OPTIMIZATIONS, handling errors.

const { compile } = require('google-closure-compiler');

compile({
  js: ['input.js'],
  compilation_level: 'ADVANCED_OPTIMIZATIONS',
  language_out: 'ECMASCRIPT5_STRICT',
  warning_level: 'VERBOSE'
}, (exitCode, stdOut, stdErr) => {
  if (exitCode !== 0) {
    console.error(stdErr);
    process.exit(exitCode);
  }
  fs.writeFileSync('output.js', stdOut);
});