npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@langgraph-js/cli

v3.0.0

Published

Build tool for LangGraph.js applications that packages graph configurations into deployable modules

Readme

LangGraph.js Bundler

A comprehensive build tool for LangGraph.js applications that packages your graph configurations into deployable modules and provides a development server.

Overview

LangGraph Bundler is a unified CLI tool that simplifies the development and deployment process of LangGraph.js applications. It provides both development and build capabilities in a single tool, automatically detecting your runtime environment and optimizing for your target deployment.

Features

  • Unified CLI: Single tool with dev and build commands
  • Multi-Runtime Support: Automatic detection and support for Bun, Deno, and Node.js
  • Zero Configuration: Automatically reads your langgraph.json file
  • Multiple Graph Support: Builds all graphs defined in your configuration
  • Hot Reload Development: File watching and automatic restart in development mode
  • ES Module Output: Generates optimized ES modules for modern environments
  • Edge Deployment Ready: Generates Hono server entrypoint for edge environments
  • Database Support: Configurable database backends (PostgreSQL, SQLite)

Installation

npm install -D @langgraph-js/bundler @langgraph-js/api
npm i -D tsx # add tsx when you use nodejs

Quick Start

1. Create Configuration

Create a langgraph.json file in your project root:

{
  "node_version": "20",
  "dependencies": ["."],
  "graphs": {
    "agent": "./src/agents/my-agent.ts:graph"
  },
  "env": ".env",
  "auth": {
    "path": "./src/auth.ts:auth"
  },
  "dist": "./dist",
  "bundler": {
    "externals": ["some-large-lib"]
  }
}

2. Development

Start the development server with hot reload:

npx langgraph-js dev

3. Build for Production

Build your application for deployment:

npx langgraph-js build

CLI Commands

Development Server

# Start development server (auto-detects runtime)
npx langgraph-js dev

# With custom port (for supported runtimes)
npx langgraph-js dev --port 3000

# Specify working directory
npx langgraph-js dev --cwd ./my-project

Runtime Behavior:

  • Bun: Uses bun run --watch dev-node.js
  • Deno: Uses deno serve -A --unstable-sloppy-imports --env-file --port 8123 --watch dev-edge.js
  • Node.js: Uses tsx watch --env-file=.env dev-node.js

Build for Production

# Build with default settings
npx langgraph-js build

# Specify database type
npx langgraph-js build --db=postgres
npx langgraph-js build --db=sqlite

# Custom working directory
npx langgraph-js build --cwd ./my-project

# Combined options
npx langgraph-js build --cwd ./my-project --db=postgres

Help and Version

# Show help
npx langgraph-js --help

# Show version
npx langgraph-js --version

Configuration

langgraph.json Structure

| Field | Type | Description | Default | | -------------- | -------- | ------------------------------- | ---------- | | node_version | string | Target Node.js version | - | | dependencies | string[] | Dependency directories | ["."] | | graphs | object | Graph name to file path mapping | {} | | env | string | Environment file path | ".env" | | auth | object | Authentication configuration | - | | dist | string | Output directory | "./dist" | | bundler | object | Bundler configuration options | - |

Graph Configuration

Define your graphs using the format: "path/to/file.ts:exportName"

{
  "graphs": {
    "chatbot": "./src/graphs/chatbot.ts:graph",
    "agent": "./src/graphs/agent.ts:agentGraph",
    "workflow": "./src/workflows/main.ts:mainWorkflow"
  }
}

Authentication Configuration

{
  "auth": {
    "path": "./src/auth.ts:authHandler"
  }
}

Bundler Configuration

Configure build-time external dependencies that should be kept external during bundling:

{
  "bundler": {
    "externals": ["some-external-package", "another-package"]
  }
}

The externals array specifies packages that should not be bundled with your application code and should remain as external dependencies. This is useful for:

  • Large libraries that should be loaded separately
  • Platform-specific modules that need to be resolved at runtime
  • Dependencies that have special loading requirements

Output Structure

After building, your dist directory will contain:

dist/
├── start.js              # Development server
├── dev-node.js          # Node.js development entry
├── dev-edge.js          # Edge runtime development entry
├── entrypoint.js        # Hono server for edge deployment
├── graphs/              # Built graph modules
│   ├── chatbot.js
│   ├── agent.js
│   └── workflow.js
└── auth.js              # Authentication module

Deployment

Node.js Deployment

# Start the production server
node dist/start.js

Edge Deployment (Cloudflare Workers, Deno Deploy)

// worker.js or main.ts
import entrypoint from './dist/entrypoint.js';

export default entrypoint;

Docker Deployment

FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --production
COPY dist/ ./dist/
EXPOSE 8000
CMD ["node", "dist/start.js"]

Environment Variables

Create a .env file for your application:

# Database configuration
DATABASE_URL=postgresql://user:password@localhost:5432/langgraph

# API Keys
OPENAI_API_KEY=your_openai_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key

# Server configuration
PORT=8000
NODE_ENV=production

Examples

Basic Agent

// src/agents/simple-agent.ts
import { StateGraph } from '@langgraph-js/api';

interface AgentState {
  messages: string[];
}

const graph = new StateGraph<AgentState>({
  channels: {
    messages: [],
  },
});

// Add nodes and edges...

export { graph };

With Authentication

// src/auth.ts
export const auth = async (request: Request) => {
  const token = request.headers.get('Authorization');
  if (!token) {
    throw new Error('Authentication required');
  }
  // Validate token...
  return { userId: 'user123' };
};

Troubleshooting

Common Issues

  1. Build Fails: Ensure all graph exports are correctly specified in langgraph.json
  2. Dev Server Won't Start: Check that the runtime environment is properly set up
  3. Module Not Found: Verify dependency paths in your configuration

Debug Mode

Set environment variable for verbose logging:

DEBUG=langgraph:* npx langgraph-js dev

Integration

This tool integrates seamlessly with:

  • LangGraph.js Core: The main graph framework
  • LangChain.js: For additional AI capabilities
  • Hono: For edge deployment
  • Various Databases: PostgreSQL, SQLite support

Repository

Find this project on GitHub: KonghaYao/langgraphjs-api

License

MIT