{"record":{"id":"cf9c9109cbe9ae07","repo":"yamadashy/repomix","slug":"output-size-exceeds-javascript-string-limit-the-r","errorCode":null,"errorMessage":"Output size exceeds JavaScript string limit. The repository contains files that are too large to process.\nPlease try:\n  - Use --ignore to exclude large files (e.g., --ignore \"docs/**\" or --ignore \"*.html\")\n  - Use --include to process only specific files\n  - Process smaller portions of the repository at a time${largeFilesInfo}","messagePattern":"Output size exceeds JavaScript string limit\\. The repository contains files that are too large to process\\.\nPlease try:\n  - Use --ignore to exclude large files \\(e\\.g\\., --ignore \"docs/\\*\\*\" or --ignore \"\\*\\.html\"\\)\n  - Use --include to process only specific files\n  - Process smaller portions of the repository at a time(.+?)","errorType":"exception","errorClass":"RepomixError","httpStatus":null,"severity":"error","filePath":"src/core/output/outputGenerate.ts","lineNumber":249,"sourceCode":"  renderContext: RenderContext,\n  processedFiles?: ProcessedFile[],\n): Promise<string> => {\n  try {\n    const compiledTemplate = getCompiledTemplate(config.output.style);\n    return `${compiledTemplate(renderContext).trim()}\\n`;\n  } catch (error) {\n    if (error instanceof RangeError && error.message === 'Invalid string length') {\n      let largeFilesInfo = '';\n      if (processedFiles && processedFiles.length > 0) {\n        const topFiles = processedFiles\n          .sort((a, b) => b.content.length - a.content.length)\n          .slice(0, 5)\n          .map((f) => `  - ${f.path} (${(f.content.length / 1024 / 1024).toFixed(1)} MB)`)\n          .join('\\n');\n        largeFilesInfo = `\\n\\nLargest files in this repository:\\n${topFiles}`;\n      }\n\n      throw new RepomixError(\n        `Output size exceeds JavaScript string limit. The repository contains files that are too large to process.\nPlease try:\n  - Use --ignore to exclude large files (e.g., --ignore \"docs/**\" or --ignore \"*.html\")\n  - Use --include to process only specific files\n  - Process smaller portions of the repository at a time${largeFilesInfo}`,\n        { cause: error },\n      );\n    }\n    throw new RepomixError(\n      `Failed to compile template: ${error instanceof Error ? error.message : 'Unknown error'}`,\n      error instanceof Error ? { cause: error } : undefined,\n    );\n  }\n};\n\nexport const generateOutput = async (\n  rootDirs: string[],\n  config: RepomixConfigMerged,","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/yamadashy/repomix/blob/f465ad909315a22120636baf03fa5e28701a50cb/src/core/output/outputGenerate.ts#L231-L267","documentation":"The fully rendered output string exceeded V8's maximum string length (~512MB/1GB). Repomix catches this during Handlebars rendering and throws this actionable error, optionally appending the largest files (with sizes) to help you shrink the pack.","triggerScenarios":"generateHandlebarOutput renders a repository whose combined file contents exceed the JS string limit; the caught RangeError 'Invalid string length' is replaced by this message including largeFilesInfo when the largest files can be computed.","commonSituations":"Packing monorepos or repos with huge generated assets (docs builds, minified bundles, lockfiles); running with no ignore patterns on very large codebases.","solutions":["Add --ignore patterns for large/generated files (e.g. --ignore \"docs/**\" or --ignore \"*.html\").","Use --include to pack only the directories you need.","Split the run: pack subdirectories separately.","Identify the files listed under 'Largest files in this repository' and exclude or trim them."],"exampleFix":"// before\nrepomix  # huge monorepo, exceeds string limit\n// after\nrepomix --ignore \"**/dist/**,**/docs/**,**/*.min.js\"","handlingStrategy":"validation","validationCode":"const total = files.reduce((n, f) => n + f.content.length, 0);\nconst MAX = 500 * 1024 * 1024; // stay under JS string limit\nif (total > MAX) {\n  const worst = [...files].sort((a, b) => b.content.length - a.content.length).slice(0, 5);\n  throw new Error(`Output ~${(total / 1e6).toFixed(0)}MB too large; exclude: ${worst.map(f => f.path).join(', ')}`);\n}","typeGuard":"null","tryCatchPattern":"try {\n  await repomixCli.run(args);\n} catch (e) {\n  if (e instanceof RepomixError && e.message.includes('Output size exceeds JavaScript string limit')) {\n    // parse the 'Largest files' section and add matching --ignore patterns, then retry\n  }\n}","preventionTips":["Always set --ignore for dist/, docs builds, minified assets and lockfiles on large repos.","Prefer --include scoping to the directories you actually need.","Split monorepo packing into per-package runs.","Check the 'Largest files' list in the error message and iterate on ignore globs."],"tags":["output","size-limit","memory","configuration"],"backgroundTag":"output-exceeds-string-limit","analyzedSha":"f465ad909315a22120636baf03fa5e28701a50cb","analyzedAt":"2026-08-29T01:27:42.024Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}