Jest
LangChain.js is a comprehensive TypeScript/JavaScript framework for building applications powered by large language models (LLMs). It provides a unified interface for connecting to 20+ LLM providers (OpenAI, Anthropic Claude, Google Gemini, AWS Bedrock, Ollama, etc.), managing document retrieval with vector stores, and orchestrating AI agents with tools, memory, and middleware capabilities.
Tech Stack
Key Features
- Universal Chat Models
- Vector Store Integrations
- Document Loaders & Text Splitters
- Agent Middleware System
- Runnables & Chains
- MCP Adapters
- Tracing & Observability
Coding Conventions
Standards and patterns used in this codebase
Use ESLint with a shared internal configuration package (@langchain/internal/eslint) that extends across all packages in the monorepo
import { config } from "@langchain/internal/eslint";
export default [...config];Use TypeScript ESM modules with .ts extension in ESLint config files (eslint.config.ts) following flat config format
export default [
...config,
{
files: ["src/**/*.ts"],
rules: {
"@typescript-eslint/no-explicit-any": "off"
}
}
];Use ES module syntax with named exports and dynamic imports for lazy loading
const { run } = await import(`./examples/${exampleRelativePath}`);
await run();Use process.exit with appropriate exit codes (0 for success, 1 for errors) and console.error for error output
try {
await run();
process.exit(0);
} catch (e) {
console.error(e);
process.exit(1);
}Use prompts library for interactive CLI input with validation and abort handling via onCancel
const res = await prompts({
type: "text",
name: "path",
message: "What is your project named?",
validate: (name) => { ... }
}, { onCancel: () => process.exit(1) });Use async fs operations (fs/promises) with path.join for cross-platform path handling
import fs from "fs";
import path from "path";
const root = path.resolve(appPath);
await fs.promises.mkdir(root, { recursive: true });Configure Vite/webpack to externalize Node.js built-in modules and provide browser fallbacks for server-only modules
resolve: {
fallback: {
fs: false,
child_process: false,
"node:child_process": false
}
}Use Docker containers for isolated environment testing with spawn for process execution and proper signal handling
const proc = spawn("docker", ["compose", "up", "--build", "--abort-on-container-exit"], {
cwd: testDir,
stdio: "inherit"
});Organize monorepo with libs/ for packages, providers/ for LLM integrations, and internal/ for shared tooling
libs/langchain-core/src, libs/providers/langchain-openai/src, internal/eslint/Use kebab-case for package and directory names, camelCase for variables and functions
@langchain/langchain-openai, createApp(), appPath, projectName