chroma-core/chroma · error · Error
Please install Ollama as a dependency with, e.g. `npm instal
Error message
Please install Ollama as a dependency with, e.g. `npm install ollama`
What it means
Static import helper for OllamaEmbeddingFunction: it wraps import("ollama") (re-shaping the module as { ollama: m }) in an unconditional try/catch, so every import failure — missing package, broken install, or bundler resolution — becomes the same 'install Ollama' message with the original error discarded. This masks non-obvious causes the same way errors 41/44/57 do.
Source
Thrown at clients/js/packages/chromadb-core/src/embeddings/OllamaEmbeddingFunction.ts:57
"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) {
throw new Error(
"Please install Ollama as a dependency with, e.g. `npm install ollama`",
);
}
}
public async generate(texts: string[]) {
await this.initClient();
return await this.ollamaClient!.embed({
model: this.model,
input: texts,
}).then((response: any) => {
return response.embeddings;
});
}
buildFromConfig(config: StoredConfig): OllamaEmbeddingFunction {
return new OllamaEmbeddingFunction({
url: config.url,View on GitHub (pinned to aecdd12c8a)
Solutions
- npm install ollama and retry
- If already installed, reproduce the swallowed error: node -e "import('ollama').then(m=>console.log('ok'),e=>console.error(e))"
- Clean reinstall from the lockfile: rm -rf node_modules && npm ci
- Switch embedding functions if the dependency is unwanted
Example fix
// before: install message despite the package being listed
// after: expose the real import error the helper swallows
// $ node -e "import('ollama').then(m=>console.log('ok'), e=>console.error(e))" Defensive patterns
Strategy: validation
Validate before calling
async function canImport(pkg: string): Promise<boolean> {
try {
await import(pkg);
return true;
} catch {
return false;
}
}
if (!(await canImport("ollama"))) {
// fail with instructions or fall back to another embedding function
} Try / catch
try {
await ef.generate(texts);
} catch (e) {
if (e instanceof Error && /install Ollama/.test(e.message)) {
// probe import('ollama') to tell missing package from broken install
}
throw e;
} Prevention
- Commit lockfiles and use npm ci in CI for reproducible optional deps
- CI smoke-import each optional provider package
- Prefer explicit embedding functions in bundled/serverless builds
When it happens
Trigger: Any rejection of the dynamic import("ollama") via OllamaEmbeddingFunction.import(): package absent, partially installed, or unresolvable by the runtime/bundler.
Common situations: node_modules desync after branch switches; exports-map resolution failures in bundled deployments; optional deps stripped by minimal CI install stages.
Related errors
- Please install chromadb-default-embed as a dependency with,
- Please install @google/generative-ai as a dependency with, e
- Please install the ollama package to use the OllamaEmbedding
- Please install the cohere-ai package to use the CohereEmbedd
- Please install the chromadb-default-embed package to use the
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/2a6e2956e2715bbd.
Report an issue: GitHub.