Hi,
Hope this finds you well. I am trying to
import { HuggingFaceInference } from ‘langchain/integrations/huggingface’;
import { PromptTemplate } from ‘langchain/prompts’;
import { RunnableSequence } from ‘langchain/schema/runnable’;
But i keep getting Cannot find module ‘langchain/integrations/huggingface’ or its corresponding type declarations.ts(2307).
i have tried uninstalling langchain, i tried restarting the Ts Server, tried installing different version of langchain but nothing seems to work
If you could please help that would be so great.
Thank you so much
1 Like
I can’t read TypeScript code at all, but it seems that up to a certain point there was a bug in the LangChain library for TS that made installation difficult.
opened 10:23AM - 04 Apr 23 UTC
closed 04:02PM - 04 Apr 23 UTC
question
env/packaging
Hi. I installed langchain for my Node Typescript project. When I try to run the … sample, I get the following errors in the terminal:
```
node_modules/langchain/dist/cache.d.ts:1:38 - error TS2307: Cannot find module 'redis' or its corresponding type declarations.
1 import type { RedisClientType } from "redis";
~~~~~~~
node_modules/langchain/dist/embeddings/cohere.d.ts:54:31 - error TS2307: Cannot find module 'cohere-ai' or its corresponding type declarations.
54 cohere: typeof import("cohere-ai");
~~~~~~~~~~~
node_modules/langchain/dist/llms/cohere.d.ts:21:31 - error TS2307: Cannot find module 'cohere-ai' or its corresponding type declarations.
21 cohere: typeof import("cohere-ai");
~~~~~~~~~~~
node_modules/langchain/dist/llms/hf.d.ts:29:36 - error TS2307: Cannot find module '@huggingface/inference' or its corresponding type declarations.
29 HfInference: typeof import("@huggingface/inference").HfInference;
~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/langchain/dist/llms/openai-chat.d.ts:2:15 - error TS2614: Module '"../util/axios-fetch-adapter.js"' has no exported member 'StreamingAxiosConfiguration'. Did you mean to use 'import StreamingAxiosConfiguration from "../util/axios-fetch-adapter.js"' instead?
2 import type { StreamingAxiosConfiguration } from "../util/axios-fetch-adapter.js";
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/langchain/dist/llms/openai.d.ts:2:15 - error TS2614: Module '"../util/axios-fetch-adapter.js"' has no exported member 'StreamingAxiosConfiguration'. Did you mean to use 'import StreamingAxiosConfiguration from "../util/axios-fetch-adapter.js"' instead?
2 import type { StreamingAxiosConfiguration } from "../util/axios-fetch-adapter.js";
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/langchain/dist/llms/replicate.d.ts:17:34 - error TS2307: Cannot find module 'replicate' or its corresponding type declarations.
17 Replicate: typeof import("replicate").Replicate;
~~~~~~~~~~~
node_modules/langchain/dist/sql_db.d.ts:1:67 - error TS2307: Cannot find module 'typeorm' or its corresponding type declarations.
1 import type { DataSource as DataSourceT, DataSourceOptions } from "typeorm";
~~~~~~~~~
node_modules/langchain/dist/text_splitter.d.ts:1:32 - error TS2307: Cannot find module '@dqbd/tiktoken' or its corresponding type declarations.
1 import type * as tiktoken from "@dqbd/tiktoken";
~~~~~~~~~~~~~~~~
node_modules/langchain/dist/util/sql_utils.d.ts:1:52 - error TS2307: Cannot find module 'typeorm' or its corresponding type declarations.
1 import type { DataSource, DataSourceOptions } from "typeorm";
~~~~~~~~~
node_modules/langchain/dist/vectorstores/chroma.d.ts:1:52 - error TS2307: Cannot find module 'chromadb' or its corresponding type declarations.
1 import type { ChromaClient as ChromaClientT } from "chromadb";
~~~~~~~~~~
node_modules/langchain/dist/vectorstores/hnswlib.d.ts:1:69 - error TS2307: Cannot find module 'hnswlib-node' or its corresponding type declarations.
1 import type { HierarchicalNSW as HierarchicalNSWT, SpaceName } from "hnswlib-node";
~~~~~~~~~~~~~~
node_modules/langchain/dist/vectorstores/pinecone.d.ts:1:42 - error TS2307: Cannot find module '@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch' or its corresponding type declarations.
1 import type { VectorOperationsApi } from "@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/langchain/dist/vectorstores/supabase.d.ts:1:37 - error TS2307: Cannot find module '@supabase/supabase-js' or its corresponding type declarations.
1 import type { SupabaseClient } from "@supabase/supabase-js";
~~~~~~~~~~~~~~~~~~~~~~~
Found 14 errors in 14 files.
Errors Files
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/cache.d.ts:1
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/embeddings/cohere.d.ts:54
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/llms/cohere.d.ts:21
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/llms/hf.d.ts:29
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/llms/openai-chat.d.ts:2
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/llms/openai.d.ts:2
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/llms/replicate.d.ts:17
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/sql_db.d.ts:1
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/text_splitter.d.ts:1
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/util/sql_utils.d.ts:1
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/vectorstores/chroma.d.ts:1
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/vectorstores/hnswlib.d.ts:1
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/vectorstores/pinecone.d.ts:1
1 ../../../../../users/adityam/documents/code/node-sandbox/node_modules/langchain/dist/vectorstores/supabase.d.ts:1
```
I did do `npm install -S langchain`. And I set all the parameters in the tsconfig.json & package.json to the recommended values.
Here is my package.json:
```json
{
"name": "sandbox",
"version": "1.0.0",
"description": "NodeJS sandbox.",
"main": "dist/index.js",
"type": "module",
"scripts": {
"start": "node dist/index.js",
"build": "tsc && npm run start"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"langchain": "^0.0.47"
},
"devDependencies": {
"@types/node": "^18.15.11"
}
}
```
And here is my tsconfig.json:
```json
{
"compilerOptions": {
"target": "ES2020",
"module": "NodeNext",
"sourceMap": true,
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"moduleResolution": "nodenext"
},
"include": [
"./src/**/*",
"./assets/**/*"
],
"exclude": [
"node_modules"
]
}
```
**What's going on? Will I have to install all these modules separately?**
It is not impossible that this is a TS2307 problem.
typescript
In any case, it seems to me that you are definitely stumbling on some TS-specific issue. If you have a recent example that worked well, the quickest thing to do is to copy it…