{"record":{"id":"59459baa54ba5614","repo":"unclecode/crawl4ai","slug":"c4a-script-compiler-not-available-please-ensure-c","errorCode":null,"errorMessage":"C4A script compiler not available. Please ensure crawl4ai.script module is properly installed.","messagePattern":"C4A script compiler not available\\. Please ensure crawl4ai\\.script module is properly installed\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"crawl4ai/async_configs.py","lineNumber":1986,"sourceCode":"                if result.success:\n                    compiled_js.extend(result.js_code)\n                else:\n                    # Format error message following existing patterns\n                    error = result.first_error\n                    error_msg = (\n                        f\"C4A Script compilation error (script {i+1}):\\n\"\n                        f\"  Line {error.line}, Column {error.column}: {error.message}\\n\"\n                        f\"  Code: {error.source_line}\"\n                    )\n                    if error.suggestions:\n                        error_msg += f\"\\n  Suggestion: {error.suggestions[0].message}\"\n                        \n                    raise ValueError(error_msg)\n                    \n            self.js_code = compiled_js\n            \n        except ImportError:\n            raise ValueError(\n                \"C4A script compiler not available. \"\n                \"Please ensure crawl4ai.script module is properly installed.\"\n            )\n        except Exception as e:\n            # Re-raise with context\n            if \"compilation error\" not in str(e).lower():\n                raise ValueError(f\"Failed to compile C4A script: {str(e)}\")\n            raise\n    \n    def is_match(self, url: str) -> bool:\n        \"\"\"Check if this config matches the given URL.\n        \n        Args:\n            url: The URL to check against this config's matcher\n            \n        Returns:\n            bool: True if this config should be used for the URL or if no matcher is set.\n        \"\"\"","sourceCodeStart":1968,"sourceCodeEnd":2004,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/crawl4ai/async_configs.py#L1968-L2004","documentation":"Raised when compiling js_source requires crawl4ai.script (the C4A compiler) and importing it fails. The core install does not include every optional dependency of the script compiler, so the feature degrades to this explicit error rather than a confusing ImportError.","triggerScenarios":"Installing crawl4ai without optional script-compiler dependencies (e.g. pip install crawl4ai instead of the full/extra variant), or a broken/partial install/venv where crawl4ai.script cannot import its third-party deps.","commonSituations":"Docker images trimmed for size; CI using minimal installs; upgrading crawl4ai where the script module's deps moved to an extra.","solutions":["Reinstall with the appropriate extras: pip install \"crawl4ai[all]\" (or the documented script/extra variant for your version)","Verify the module imports: python -c \"import crawl4ai.script\"","If you do not need C4A scripts, move the JS into plain js_code / js_source as standard JavaScript instead of DSL","Repair a broken venv: pip install --force-reinstall crawl4ai"],"exampleFix":"// before\npip install crawl4ai\ncfg = CrawlerRunConfig(js_source=my_c4a_script)\n// after\npip install \"crawl4ai[all]\"\ncfg = CrawlerRunConfig(js_source=my_c4a_script)","handlingStrategy":"fallback","validationCode":"try:\n    import crawl4ai.script  # noqa\n    HAS_C4A = True\nexcept ImportError:\n    HAS_C4A = False\n\nrun_kwargs = {\"js_source\": scripts} if HAS_C4A else {\"js_code\": plain_js_equivalent}","typeGuard":null,"tryCatchPattern":"try:\n    cfg = CrawlerRunConfig(js_source=scripts)\nexcept ValueError as e:\n    if \"compiler not available\" in str(e):\n        cfg = CrawlerRunConfig(js_code=plain_js)  # fallback to plain JS\n    else:\n        raise","preventionTips":["Install with extras: pip install \"crawl4ai[all]\"","Smoke-test `import crawl4ai.script` in Docker/CI images","Keep a plain-JS variant of critical scripts as fallback"],"tags":["installation","c4a-script","dependencies","import-error"],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}