{"id":25646,"library":"google-closure-compiler-osx","title":"google-closure-compiler-osx","description":"The OS X native binary distribution of Google's Closure Compiler, a JavaScript optimization and type-checking tool. This package provides the compiler via a Java binary specifically for macOS. Current stable version: 20240317.0.0. Releases follow upstream Closure Compiler releases, typically monthly. This is the platform-specific variant for macOS; equivalent packages exist for linux, windows, and a Java-based generic one. Key differentiator: optimized native binary for macOS vs running via Java.","status":"active","version":"20240317.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/google/closure-compiler-npm#master","tags":["javascript","compiler","optimizer","minifier","closure","java"],"install":[{"cmd":"npm install google-closure-compiler-osx","lang":"bash","label":"npm"},{"cmd":"yarn add google-closure-compiler-osx","lang":"bash","label":"yarn"},{"cmd":"pnpm add google-closure-compiler-osx","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"The Java-based fallback if native binary fails","package":"google-closure-compiler-java","optional":true}],"imports":[{"note":"ESM only; no default export.","wrong":"const getNativeImagePath = require('google-closure-compiler-osx').getNativeImagePath","symbol":"getNativeImagePath","correct":"import { getNativeImagePath } from 'google-closure-compiler-osx'"},{"note":"CommonJS fallback; ESM preferred but platform is the default export in CJS.","wrong":"import platform from 'google-closure-compiler-osx'","symbol":"platform","correct":"const platform = require('google-closure-compiler-osx')"},{"note":"Exposed as a string path to the native binary.","wrong":"","symbol":"binaryPath","correct":"import { binaryPath } from 'google-closure-compiler-osx'"}],"quickstart":{"code":"const { exec } = require('child_process');\nconst path = require('path');\nconst cc = require('google-closure-compiler-osx');\nconst compilerPath = cc.binaryPath;\n\n// Compile a simple JavaScript file\nconst child = exec(`${compilerPath} --compilation_level SIMPLE_OPTIMIZATIONS --js input.js --js_output_file output.min.js`);\nchild.stdout.on('data', (data) => console.log(data));\nchild.stderr.on('data', (data) => console.error(data));","lang":"javascript","description":"Shows how to use the Google Closure Compiler native binary for macOS to minify a JavaScript file using simple optimizations."},"warnings":[{"fix":"Update to version >=20230501 or use the Java fallback via google-closure-compiler-java.","message":"The native binary may require Rosetta 2 on Apple Silicon Macs for versions before 2023.","severity":"gotcha","affected_versions":"<20230501"},{"fix":"Use google-closure-compiler-linux or google-closure-compiler-windows for other platforms.","message":"The package is platform-specific; installing on non-macOS will fail or fallback to Java.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to >=20201001 or ensure JRE is installed if using older versions.","message":"Switched from bundled Java to native binary in v20201001. Old versions were Java-based requiring JRE.","severity":"breaking","affected_versions":"<20201001"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install with npm install google-closure-compiler-osx --save-dev","cause":"Package not installed or not available on this platform","error":"Error: Cannot find module 'google-closure-compiler-osx'"},{"fix":"Check that input file exists and path is absolute or correctly relative.","cause":"Input file path is incorrect or missing","error":"Error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.io.FileNotFoundException: /path/to/input.js"},{"fix":"Remove the -Dfile.encoding=UTF-8 flag from your command.","cause":"Encoding flag not supported on native binary","error":"WARNING: -Dfile.encoding=UTF-8 not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}