The Google Closure Compiler npm package (v20260602.0.0) provides the official Closure Compiler binary for JavaScript checking, optimization, and minification. Released monthly from the upstream Closure Compiler repository. It supports three execution modes: a native binary (Linux/macOS/Windows), a Java jar (requires Java), and an npx runner. Key differentiator: offers both simple and advanced compilation levels (including dead code elimination, type checking, and global renamings) unmatched by simpler minifiers like UglifyJS or Terser. It also includes Grunt and Gulp plugins, and an official webpack plugin. Note: the installed package contains a native binary or Java jar, not JavaScript. The Java version generally yields faster compilations for large projects.
npm install google-closure-compilerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows programmatic usage of the Closure Compiler with ESM import, basic compilation options, and async execution via promisify.
Migrate to ESM imports. Use dynamic import() if needed in CommonJS project.
Replace import { compiler } with import compiler.Install platform-specific package: npm install @google-closure-compiler-linux-x64
Use the compiler instance from the default export; do not attempt to require the binary path.
Use double quotes around glob patterns in options object: js: '"src/**/*.js"'
Run npm install google-closure-compiler and ensure import path does not include subfolders (unless using plugin subpaths like /gulp).
Replace `import { compiler }` with `import compiler` and use new compiler.compiler().Install the appropriate platform package: npm install @google-closure-compiler-linux-x64 (or -darwin-x64, -win32-x64).