{"id":25083,"library":"closurecompiler","title":"ClosureCompiler.js","description":"A Node.js wrapper for Google Closure Compiler that automatically downloads and sets up a JRE (from OpenJDK) and the compiler JAR. Version 1.6.1 (circa 2015) is the last stable release. This project is **deprecated** and no longer maintained; users should migrate to google-closure-compiler or google-closure-compiler-js. Key differentiator: self-contained (bundles JRE), but outdated compared to official or Java-free alternatives.","status":"deprecated","version":"1.6.1","language":"javascript","source_language":"en","source_url":"https://github.com/dcodeIO/ClosureCompiler.js","tags":["javascript","closure compiler","closure","compiler","util","utility"],"install":[{"cmd":"npm install closurecompiler","lang":"bash","label":"npm"},{"cmd":"yarn add closurecompiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add closurecompiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides Node.js externs for closure compiler","package":"closurecompiler-externs","optional":true}],"imports":[{"note":"CJS only; no default ESM export.","wrong":"import ClosureCompiler from 'closurecompiler'","symbol":"compile","correct":"var ClosureCompiler = require('closurecompiler');"},{"note":"Second argument must be options object, not callback.","wrong":"ClosureCompiler.compile(files, callback, options)","symbol":"ClosureCompiler.compile","correct":"ClosureCompiler.compile(files, options, callback)"},{"note":"Use shell redirection for output; --js_output_file is not supported.","wrong":"ccjs sourceFiles... --js_output_file output.js","symbol":"ccjs CLI","correct":"ccjs sourceFiles... [options] > output.js"}],"quickstart":{"code":"var ClosureCompiler = require('closurecompiler');\nClosureCompiler.compile(['input.js'], {\n    compilation_level: 'ADVANCED_OPTIMIZATIONS',\n    warning_level: 'VERBOSE',\n    externs: ['node']\n}, function(err, result) {\n    if (err) console.error(err);\n    else console.log(result);\n});","lang":"javascript","description":"Demonstrates basic usage: compile a JavaScript file with advanced optimizations and Node.js externs."},"warnings":[{"fix":"Migrate to google-closure-compiler or google-closure-compiler-js","message":"This package is deprecated. Alternatives: google-closure-compiler, google-closure-compiler-js","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Install Java beforehand to avoid the download","message":"Requires Java runtime; if JRE not found, package may download a bundled OpenJDK ~45MB","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use compilation_level instead of compilationLevel","message":"Options are case-insensitive in the API but must be snake_case (not camelCase)","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Redirect stdout to file: ccjs files > output.js","message":"The --js_output_file flag is NOT supported; use shell redirection","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install Java or ensure JAVA_HOME is set","cause":"No JRE/JDK installed and automatic download failed","error":"Error: Could not find any Java installation"},{"fix":"Increase JVM heap via options: -xmx2048m","cause":"Out of memory during compilation of large codebase","error":"FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed"},{"fix":"Install globally with -g or check Java installation","cause":"ccjs command not found or Java not available","error":"Error: spawn ENOENT"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}