langchain-ai / langchainjs

🦜🔗 Build context-aware reasoning applications 🦜🔗
https://js.langchain.com/docs/
MIT License
12.57k stars 2.15k forks source link

Dependencies are not installed with npm i langchain and resolution-mode issue #2879

Closed sivadassilpa closed 1 year ago

sivadassilpa commented 1 year ago

@dosu-bot

I have an issue like this `Starting compilation in watch mode...

node_modules/langchain/dist/document_loaders/fs/buffer.d.ts:1:23 - error TS1452: 'resolution-mode' assertions are only supported when moduleResolution is node16 or nodenext.

1 ///


node_modules/langchain/dist/document_loaders/fs/buffer.d.ts:2:23 - error TS1452: 'resolution-mode' assertions are only supported when moduleResolution is node16 or nodenext.

2 ///

node_modules/langchain/dist/document_loaders/fs/directory.d.ts:1:23 - error TS1452: 'resolution-mode' assertions are only supported when moduleResolution is node16 or nodenext.

1 ///


node_modules/langchain/dist/document_loaders/fs/directory.d.ts:2:23 - error TS1452: 'resolution-mode' assertions are only supported when moduleResolution is node16 or nodenext.

2 ///

node_modules/langchain/dist/document_loaders/fs/pdf.d.ts:1:22 - error TS6053: File 'C:/Users/CibusCell/Desktop/work/cibuscell-dashboard-api/node_modules/langchain/src/types/pdf-parse.d.ts' not found.

1 ///


node_modules/langchain/dist/document_loaders/fs/pdf.d.ts:2:23 - error TS1452: 'resolution-mode' assertions are only supported when moduleResolution is node16 or nodenext.

2 ///

node_modules/langchain/dist/document_loaders/fs/pdf.d.ts:15:32 - error TS2307: Cannot find module 'pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js' or its corresponding type declarations.

15 getDocument: typeof import("pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js").getDocument;


node_modules/langchain/dist/document_loaders/fs/text.d.ts:1:23 - error TS1452: 'resolution-mode' assertions are only supported when moduleResolution is node16 or nodenext.

1 ///

node_modules/langchain/dist/embeddings/cohere.d.ts:50:31 - error TS2307: Cannot find module 'cohere-ai' or its corresponding type declarations.

50 cohere: typeof import("cohere-ai");


node_modules/langchain/dist/llms/cohere.d.ts:31:31 - error TS2307: Cannot find module 'cohere-ai' or its corresponding type declarations.

31 cohere: typeof import("cohere-ai");

node_modules/langchain/dist/llms/hf.d.ts:37:36 - error TS2307: Cannot find module '@huggingface/inference' or its corresponding type declarations.

37 HfInference: typeof import("@huggingface/inference").HfInference;


node_modules/langchain/dist/llms/replicate.d.ts:23:34 - error TS2307: Cannot find module 'replicate' or its corresponding type declarations.

23 Replicate: typeof import("replicate").default;

node_modules/langchain/dist/vectorstores/chroma.d.ts:1:64 - error TS2307: Cannot find module 'chromadb' or its corresponding type declarations.

1 import type { ChromaClient as ChromaClientT, Collection } from "chromadb";


node_modules/langchain/dist/vectorstores/chroma.d.ts:2:28 - error TS2307: Cannot find module 'chromadb/dist/main/types.js' or its corresponding type declarations.

2 import type { Where } from "chromadb/dist/main/types.js";

node_modules/langchain/dist/vectorstores/pinecone.d.ts:5:46 - error TS2307: Cannot find module '@pinecone-database/pinecone' or its corresponding type declarations.

5 type VectorOperationsApi = ReturnTypeimport("@pinecone-database/pinecone").PineconeClient["Index"];


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";

node_modules/langchain/dist/vectorstores/supabase.d.ts:2:45 - error TS2307: Cannot find module '@supabase/postgrest-js' or its corresponding type declarations.

2 import type { PostgrestFilterBuilder } from "@supabase/postgrest-js";


My tsconfig.json is {
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
}
}
`
Any idea how to resolve this???
dosubot[bot] commented 1 year ago

🤖

Hello,

The errors you're encountering seem to be related to the TypeScript configuration and missing dependencies in your project. Here are some steps you can take to resolve these issues:

  1. Update your TypeScript configuration: The 'resolution-mode' assertions are only supported when moduleResolution is node16 or nodenext. You can add "moduleResolution": "node16" to your tsconfig.json file.

  2. Install missing dependencies: The errors indicate that certain modules cannot be found. These modules are likely peer dependencies of langchainjs that need to be installed separately. You can install these dependencies using npm or yarn. For example:

npm install cohere-ai@6.0.0
npm install chromadb
npm install @huggingface/inference
npm install replicate
npm install @supabase/supabase-js
npm install @supabase/postgrest-js
  1. Skip library type checking: You can add "skipLibCheck": true to your tsconfig.json file. This will skip type checking of all declaration files (*.d.ts).

  2. Ensure you have the latest version of langchainjs installed: Uninstall the current version using npm uninstall langchain and then reinstall it using npm install -S langchain.

  3. Use Yarn for dependency management: The langchainjs project is configured to use Yarn as its package manager. If you're not already using Yarn, you can install it with npm install -g yarn and then run yarn install to install the project dependencies.

  4. Ensure you're using the correct Node.js version: The minimum required version of Node.js for the langchainjs repository is 20. You can check your Node.js version with node -v and update it if necessary.

Please try these steps and let me know if you're still encountering issues.

Sources


This response is meant to be useful and save you time. 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.

If you want to continue the conversation, start your reply with @dosu-bot.

sivadassilpa commented 1 year ago

It was solved when i added "skipLibCheck": true to my tsconfig and I deleted the tsconfi.eslint.json file