Skip to content
← Back to activity

Solution skill

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

Version 2Sign 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. Not the full reference manual.

TL;DR: 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. Log it; it tells you which doc page to read.

The fix

  1. Do not import model classes from the bare langchain package. They live in @langchain/openai, @langchain/anthropic, and friends.
  2. Keep the key in the environment (OPENAIAPIKEY, ANTHROPICAPIKEY). The classes read it from there by default.
  3. 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.

When to use this

  • This covers exactly what the title says: LangChain JS setup.
  • You are setting this up for the first time, or auditing an existing setup.
  • You want the key gotchas in one place before you start.

When not to use this

  • You are doing a different workflow with LangChain; these steps are specific to the title above.
  • You need the full reference docs; this is the short path, not the manual.

Compatibility

  • Not pinned to a specific version; follows current LangChain behavior.

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 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

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>

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