Closed aqibamir closed 6 months ago
Answer generated by a 🤖
From your description, it appears that you're encountering two main issues. The first is that the chromadb
package is not installed, and the second is that the fetch
function, which is typically available in a browser environment, is not defined in your Node.js environment.
To address the first issue, you can install the chromadb
package. Although the error message suggests using npm, since you're working with a Python project, it's more likely that you need to install it using pip. You can do this by running pip install chromadb
in your terminal.
For the second issue, you can add the fetch
functionality to your Node.js environment by installing a package like node-fetch
. You can install it using npm by running npm install node-fetch
in your terminal. After installing, you can import fetch
from node-fetch
in your JavaScript code like so: const fetch = require('node-fetch');
.
Here are the commands you can run:
pip install chromadb
npm install node-fetch
And here's how you can import fetch
in your JavaScript code:
const fetch = require('node-fetch');
Please note that while this solution should generally resolve the issues you're facing, the exact solution may vary depending on your specific project setup and environment. If you find that this solution works and you believe it's a bug that could impact other users, feel free to make a pull request to help improve the project.
This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
any solution ?
Having this same issue after updating my chromadb npm package to 1.5.11 in order to get auth support. Now I am getting the error
(node:50497) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. (Use
node --trace-warnings ...to show where the warning was created) error Error: Please install chromadb as a dependency with, e.g.
npm install -S chromadb at Chroma.imports (file://=/node_modules/langchain/dist/vectorstores/chroma.js:287:19)
Facing same error with langchain 0.0.153 and chroma client 1.5.11
rollback to 1.5.6
Rolling back to 1.5.6 did not resolve the issue for me
+1
+1
@VikashLoomba Did you manage to solve it ? I also get a similar error.
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use node --trace-warnings ...
to show where the warning was created)
F:\Repositories\typelly\backend\node_modules\langchain\dist\vectorstores\chroma.cjs:313
throw new Error("Please install chromadb as a dependency with, e.g. npm install -S chromadb
");
^
Error: Please install chromadb as a dependency with, e.g. npm install -S chromadb
at Function.imports (F:\Repositories\typelly\backend\node_modules\langchain\dist\vectorstores\chroma.cjs:313:19)
at Chroma.ensureCollection (F:\Repositories\typelly\backend\node_modules\langchain\dist\vectorstores\chroma.cjs:115:42)
at Chroma.addVectors (F:\Repositories\typelly\backend\node_modules\langchain\dist\vectorstores\chroma.cjs:152:28)
at Function.fromDocuments (F:\Repositories\typelly\backend\node_modules\langchain\dist\vectorstores\chroma.cjs:288:9)
at F:\Repositories\typelly\backend\src\controllers\ai_app\ai.app.controller.ts:66:37
Attached is where the code giving the error. I have installed chromadb but still get this error.
It looks like await import("chromadb")
syntax does not support on the .cjs
file. I managed to work around on this by
const { ChromaClient } = require("chromadb")
npx patch-package langchain
in order to create patches
directory that contains diff between both versions."postinstall": "patch-package"
so it will patch the change after install packages.@VikashLoomba Did you manage to solve it ? I also get a similar error.
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. (Use
node --trace-warnings ...
to show where the warning was created)F:\Repositories\typelly\backend\node_modules\langchain\dist\vectorstores\chroma.cjs:313 throw new Error("Please install chromadb as a dependency with, e.g.
npm install -S chromadb
"); ^ Error: Please install chromadb as a dependency with, e.g.npm install -S chromadb
at Function.imports (F:\Repositories\typelly\backend\node_modules\langchain\dist\vectorstores\chroma.cjs:313:19) at Chroma.ensureCollection (F:\Repositories\typelly\backend\node_modules\langchain\dist\vectorstores\chroma.cjs:115:42) at Chroma.addVectors (F:\Repositories\typelly\backend\node_modules\langchain\dist\vectorstores\chroma.cjs:152:28) at Function.fromDocuments (F:\Repositories\typelly\backend\node_modules\langchain\dist\vectorstores\chroma.cjs:288:9) at F:\Repositories\typelly\backend\src\controllers\ai_app\ai.app.controller.ts:66:37Attached is where the code giving the error. I have installed chromadb but still get this error.
I managed to solve it, I have a repo called HelloPDF with the code on my profile
System Info
Error: Please install chromadb as a dependency with, e.g.
npm install -S chromadb
at Function.imports (file:///home/aqib/backend-11/vision/node_modules/langchain/dist/vectorstores/chroma.js:160:19) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Chroma.ensureCollection (file:///home/aqib/backend-11/vision/node_modules/langchain/dist/vectorstores/chroma.js:61:42) at async Chroma.addVectors (file:///home/aqib/backend-11/vision/node_modules/langchain/dist/vectorstores/chroma.js:88:28) at async Chroma.addDocuments (file:///home/aqib/backend-11/vision/node_modules/langchain/dist/vectorstores/chroma.js:56:9) at async Function.fromDocuments (file:///home/aqib/backend-11/vision/node_modules/langchain/dist/vectorstores/chroma.js:145:9) at async add (file:///home/aqib/backend-11/vision/vectorStore/db.js:24:5) at async run (file:///home/aqib/backend-11/vision/vectorStore/insertDocs.js:6:3) node:internal/process/promises:279 triggerUncaughtException(err, true / fromPromise /); ^Got this when I console Logged the error ReferenceError: fetch is not defined at Object. (/home/aqib/backend-11/vision/node_modules/chromadb/dist/main/generated/runtime.js:17:24)
at Module._compile (node:internal/modules/cjs/loader:1196:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
at Module.load (node:internal/modules/cjs/loader:1074:32)
at Function.Module._load (node:internal/modules/cjs/loader:909:12)
at Module.require (node:internal/modules/cjs/loader:1098:19)
at require (node:internal/modules/cjs/helpers:108:18)
at Object. (/home/aqib/backend-11/vision/node_modules/chromadb/dist/main/generated/api.js:17:19)
at Module._compile (node:internal/modules/cjs/loader:1196:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
Who can help?
No response
Information
Related Components
Reproduction
Call any Chroma method to reproduce this issue
Expected behavior
It should've inserted the documents