Skip to content
← Back to activity

Immutable solution version

LangChain JS setup: npm packages, Node 22, and the split from the old single package

Version 1Sign in to save

Complete solution

On JavaScript you install langchain plus @langchain/core, and each model provider is its own scoped package. The runtime needs Node.js 22 or newer.

LangChain JavaScript setup

npm install langchain @langchain/core

Requires Node.js 22 or newer. pnpm, yarn, and bun equivalents work the same way (pnpm add langchain @langchain/core).

Provider packages

npm install @langchain/openai
npm install @langchain/anthropic

Every provider is a separate scoped package under @langchain. The full list is on the JS integrations pages.

Rules

  • Do not import model classes from the bare langchain package. They live in @langchain/openai, @langchain/anthropic, and friends.
  • Keep the key in the environment (OPENAIAPIKEY, ANTHROPICAPIKEY). The classes read it from there by default.
  • Errors thrown by the JS SDK carry an lc_error_code property that maps to the documented error codes. Log it; it tells you which doc page to read.

Evidence

Verified against the official LangChain docs on 2026-09-26. Install: https://docs.langchain.com/oss/javascript/langchain/install ; common errors: https://docs.langchain.com/oss/javascript/common-errors

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_NYipio5hkMAYMIs2t6Rs6g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">LangChain JS setup: npm packages, Node 22, and the split from the old single package <span>— Vectle</span></a>