chroma-core/chroma · error · Error
Please install the ollama package to use the OllamaEmbedding
Error message
Please install the ollama package to use the OllamaEmbeddingFunction, `npm install -S ollama`
What it means
OllamaEmbeddingFunction.initClient() lazily dynamic-imports the optional ollama npm package on the first generate() call and constructs new ollama.Ollama({ host: this.url }). If the import fails with MODULE_NOT_FOUND, this install-hint error is thrown; other errors are re-thrown unchanged. The package is optional so chromadb-core does not force it on users of other providers.
Source
Thrown at clients/js/packages/chromadb-core/src/embeddings/OllamaEmbeddingFunction.ts:38
// for the openai npm package, and the constructor can not be async
if (url && url.endsWith("/api/embeddings")) {
this.url = url.slice(0, -"/api/embeddings".length);
} else {
this.url = url;
}
this.model = model;
}
private async initClient() {
if (this.ollamaClient) return;
try {
// @ts-ignore
const { ollama } = await OllamaEmbeddingFunction.import();
this.ollamaClient = new ollama.Ollama({ host: this.url });
} catch (e) {
// @ts-ignore
if (e.code === "MODULE_NOT_FOUND") {
throw new Error(
"Please install the ollama package to use the OllamaEmbeddingFunction, `npm install -S ollama`",
);
}
throw e;
}
}
/** @ignore */
static async import(): Promise<{
// @ts-ignore
ollama: typeof import("ollama");
}> {
try {
// @ts-ignore
const { ollama } = await import("ollama").then((m) => ({ ollama: m }));
// @ts-ignore
return { ollama };
} catch (e) {View on GitHub (pinned to aecdd12c8a)
Solutions
- npm install -S ollama in the app that runs the client, then retry
- If installed but failing, test the import directly: node -e "import('ollama').then(()=>console.log('ok'),e=>console.error(e))"
- Verify the Ollama server itself is reachable at the configured url once the package imports cleanly
- Use an explicit different embedding function if you do not want the dependency
Example fix
// before
const ef = new OllamaEmbeddingFunction({ url: "http://localhost:11434", model: "nomic-embed-text" });
await ef.generate(["ping"]); // -> Please install the ollama package...
// after
// $ npm install -S ollama
await ef.generate(["ping"]); // ok Defensive patterns
Strategy: validation
Validate before calling
async function ollamaPkgAvailable(): Promise<boolean> {
try {
await import("ollama");
return true;
} catch {
return false;
}
}
// before using the Ollama embedding function:
if (!(await ollamaPkgAvailable())) throw new Error("Install the ollama npm package (and ensure the Ollama server is running)"); Try / catch
try {
await collection.add({ ids, documents });
} catch (e) {
if (e instanceof Error && /install the ollama package/.test(e.message)) {
// dependency missing: install it or switch embedding function
}
throw e;
} Prevention
- Add the ollama package as an explicit dependency if you use that embedding function
- Smoke-test generate(["ping"]) at startup — it also surfaces a down Ollama server early
- Keep the Ollama server URL in validated config, not ad-hoc strings
When it happens
Trigger: Creating a collection with the Ollama embedding function and triggering the first generate()/add() in a project where the ollama npm package is not installed (the Ollama server being down is a separate, later failure).
Common situations: Installing chromadb without the ollama client package; monorepo hoisting dropping optional deps; bundler builds where the error lacks .code (a raw error appears instead); slim Docker images.
Related errors
- Please install the chromadb-default-embed package to use the
- Please install the openai package to use the OpenAIEmbedding
- Please install chromadb-default-embed as a dependency with,
- Please install the @google/generative-ai package to use the
- Please install Ollama as a dependency with, e.g. `npm instal
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/6ced64895cb314be.
Report an issue: GitHub.