Installation
This guide covers installing LangChain.js and its dependencies. LangChain.js is distributed as npm packages and supports multiple JavaScript runtimes.Prerequisites
Before installing LangChain.js, ensure you have:Node.js 20.x or higher
LangChain.js requires Node.js version 20.x, 22.x, or 24.x.
If you need to manage multiple Node.js versions, consider using nvm (Node Version Manager).
Installing LangChain
Install the mainlangchain package using your preferred package manager:
langchain package includes:
- Core LangChain functionality
- Agent implementations
- Chains and memory systems
- Integration with
@langchain/core(automatically installed as a dependency)
Installing Core Packages
Depending on your use case, you may want to install additional core packages:@langchain/core
The@langchain/core package contains core abstractions and interfaces. It’s automatically installed with langchain, but you can also use it standalone:
@langchain/community
Community-maintained integrations for various tools and services:@langchain/textsplitters
Utilities for splitting text and documents:Installing Model Providers
To use LLMs, you’ll need to install at least one model provider package. Here are the most popular options:OpenAI
Anthropic (Claude)
Google Vertex AI
Google Generative AI
Other Providers
LangChain.js supports many other providers:| Provider | Package |
|---|---|
| Mistral AI | @langchain/mistralai |
| Cohere | @langchain/cohere |
| Groq | @langchain/groq |
| Ollama | @langchain/ollama |
| AWS Bedrock | @langchain/aws |
| Cerebras | @langchain/cerebras |
| DeepSeek | @langchain/deepseek |
| xAI | @langchain/xai |
Environment Setup
After installing packages, you’ll need to set up API keys for the services you plan to use.Verifying Installation
Create a simple test file to verify your installation:test.ts
TypeScript Configuration
LangChain.js is written in TypeScript. For the best development experience, configure yourtsconfig.json:
tsconfig.json
LangChain.js uses ES modules by default. Make sure your
package.json includes "type": "module" if using Node.js.Alternative Runtimes
Deno
LangChain.js works with Deno. Import packages from npm:Bun
Install packages normally with Bun’s package manager:Browser
For browser environments, use a bundler like Webpack, Vite, or Rollup. Most LangChain functionality works in browsers, but some features (like file system access) are Node.js-specific.Next Steps
Now that you have LangChain.js installed:Quickstart
Build your first LangChain application with a step-by-step guide
Learn Core Concepts
Understand the fundamental concepts behind LangChain
Browse Integrations
Explore all available model providers and integrations
API Reference
Dive into the complete API documentation
