{"record":{"id":"1d93f25a46b375a5","repo":"FlowiseAI/Flowise","slug":"please-install-chromadb-as-a-dependency-with-e-g","errorCode":null,"errorMessage":"Please install chromadb as a dependency with, e.g. `npm install -S chromadb`","messagePattern":"Please install chromadb as a dependency with, e\\.g\\. `npm install -S chromadb`","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/components/nodes/vectorstores/Chroma/core.ts","lineNumber":333,"sourceCode":"     * @param embeddings An `Embeddings` instance used to generate embeddings for the documents.\n     * @param dbConfig A `ChromaLibArgs` object containing the configuration for the Chroma database.\n     * @returns A promise that resolves with a new `Chroma` instance.\n     */\n    static async fromExistingCollection(embeddings: EmbeddingsInterface, dbConfig: ChromaLibArgs): Promise<Chroma> {\n        const instance = new this(embeddings, dbConfig)\n        await instance.ensureCollection()\n        return instance\n    }\n\n    /** @ignore */\n    static async imports(): Promise<{\n        ChromaClient: typeof ChromaClientT\n    }> {\n        try {\n            const { ChromaClient } = await import('chromadb')\n            return { ChromaClient }\n        } catch {\n            throw new Error('Please install chromadb as a dependency with, e.g. `npm install -S chromadb`')\n        }\n    }\n}\n\n/**\n * Generates a unique collection name if none is provided.\n */\nfunction ensureCollectionName(collectionName?: string) {\n    if (!collectionName) {\n        return `langchain-${uuid.v4()}`\n    }\n    return collectionName\n}\n\n/**\n * Sanitizes metadata to only include Chroma-compatible primitive values.\n * Chroma metadata only supports boolean, number, string, and null values.\n * Arrays and objects are JSON stringified to preserve the data.","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/vectorstores/Chroma/core.ts#L315-L351","documentation":"Chroma.imports() dynamically imports 'chromadb'; if the module cannot be resolved the install hint is thrown. This is a dependency-resolution error, not a runtime logic error.","triggerScenarios":"First call to fromDocuments / ensureCollection / any path that triggers Chroma.imports(). Fails when chromadb is absent from node_modules, the bundle excluded it, or a monorepo hoisting issue prevents resolution.","commonSituations":"Missing `npm install chromadb`, monorepo with hoisting where the package lives only in a sibling workspace, bundler tree-shaking or marking it external incorrectly, or a Node version incompatible with the package's ESM/CJS layout.","solutions":["Run `npm install chromadb` (or `pnpm add chromadb` / `yarn add chromadb`) in the workspace that resolves this module.","In a monorepo, ensure the package is installed in the consuming workspace or hoisted correctly.","If bundling, ensure chromadb is not erroneously externalized or vice-versa for the target runtime."],"exampleFix":"// before: chromadb not installed -> throw on dynamic import\n\n// after (terminal)\nnpm install chromadb","handlingStrategy":"validation","validationCode":"// preflight at startup\nasync function ensureChroma() {\n  try {\n    await import('chromadb')\n  } catch {\n    throw new Error('chromadb not installed. Run: npm install chromadb')\n  }\n}\nawait ensureChroma()","typeGuard":"async function isChromadbInstalled(): Promise<boolean> {\n  try { await import('chromadb'); return true } catch { return false }\n}","tryCatchPattern":"try {\n  await Chroma.imports()\n} catch (e) {\n  if (/install chromadb/i.test(String(e))) {\n    throw new Error('Missing optional dependency. Run `npm install chromadb` then restart.', { cause: e })\n  }\n  throw e\n}","preventionTips":["Add chromadb to package.json dependencies, not optionalDependencies, if you always need it.","In monorepos, install in the consuming workspace.","Run a startup dependency preflight that imports required packages."],"tags":["chroma","dependency","install","import"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}