{"record":{"id":"df47655db43e6f56","repo":"chroma-core/chroma","slug":"please-install-the-voyageai-package-to-use-the-voy","errorCode":null,"errorMessage":"Please install the voyageai package to use the VoyageAIEmbeddingFunction, `npm install -S voyageai`","messagePattern":"Please install the voyageai package to use the VoyageAIEmbeddingFunction, `npm install -S voyageai`","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clients/js/packages/chromadb-core/src/embeddings/VoyageAIEmbeddingFunction.ts","lineNumber":81,"sourceCode":"      );\n    }\n    this.apiKey = apiKey;\n    this.model = model;\n    this.apiKeyEnvVar = api_key_env_var;\n  }\n\n  private async initClient() {\n    if (this.voyageAiApi) return;\n    try {\n      // @ts-ignore\n      this.voyageAiApi = await import(\"voyageai\").then((voyageai) => {\n        // @ts-ignore\n        return new VoyageAIAPI({ apiKey: this.apiKey });\n      });\n    } catch (e) {\n      // @ts-ignore\n      if (e.code === \"MODULE_NOT_FOUND\") {\n        throw new Error(\n          \"Please install the voyageai package to use the VoyageAIEmbeddingFunction, `npm install -S voyageai`\",\n        );\n      }\n      throw e;\n    }\n  }\n\n  public async generate(texts: string[]): Promise<number[][]> {\n    await this.initClient();\n    // @ts-ignore\n    return await this.voyageAiApi.createEmbedding({\n      model: this.model,\n      input: texts,\n    });\n  }\n\n  buildFromConfig(config: StoredConfig): VoyageAIEmbeddingFunction {\n    return new VoyageAIEmbeddingFunction({","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/js/packages/chromadb-core/src/embeddings/VoyageAIEmbeddingFunction.ts#L63-L99","documentation":"VoyageAIEmbeddingFunction.initClient() lazily does `await import('voyageai')` on the first generate(); if the rejection carries code MODULE_NOT_FOUND it rethrows as this friendly install hint, otherwise the original error propagates. Caveat: under Node ESM a missing package actually fails with ERR_MODULE_NOT_FOUND (a TypeError without .code === 'MODULE_NOT_FOUND'), so you may see the raw import error instead — same root cause, missing optional dependency.","triggerScenarios":"First collection.add()/query() using VoyageAIEmbeddingFunction without `voyageai` in dependencies; package present in the workspace root but not resolvable from the package constructing the function; buildFromConfig restoring a voyageai-configured collection on a machine without the package.","commonSituations":"Following Chroma docs without installing the optional provider SDK; monorepo hoisting issues; CI cache built before the dependency was added.","solutions":["npm install voyageai (or yarn/pnpm equivalent) in the package that creates the embedding function.","Verify resolution in the failing runtime: node -e \"import('voyageai').then(m => console.log(!!m.VoyageAIAPI)).catch(e => console.error(e.code || e.message))\".","If you instead see ERR_MODULE_NOT_FOUND or a TypeError from import, it is the same missing-package cause — install it.","Rebuild CI/Docker caches after adding the dependency."],"exampleFix":"# before\nnpm install chromadb\n# VoyageAIEmbeddingFunction used -> first add() throws install hint\n\n# after\nnpm install chromadb voyageai","handlingStrategy":"validation","validationCode":"try {\n  await import(\"voyageai\");\n} catch {\n  throw new Error(\"voyageai package missing. Run: npm install voyageai\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare optional provider SDKs (voyageai, @xenova/transformers) explicitly in the consuming package's dependencies.","Add a startup preflight that imports each optional SDK your active embedding functions need."],"tags":["voyageai","embeddings","optional-dependency","npm"],"backgroundTag":"missing-npm-dependency","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}