Could not resolve "node:async_hooks" in deno. #215

Closed
opened 2026-02-15 17:17:26 -05:00 by yindo · 1 comment
Owner

Originally created by @mrfy on GitHub (Mar 25, 2025).

I have a Deno project where I want to use LangGraph. However, during the build process (I'm using esbuild), I encounter the following error:

 [ERROR] Could not resolve "node:async_hooks"

    node_modules/@langchain/langgraph/dist/setup/async_local_storage.js:2:34:
      2  import { AsyncLocalStorage } from "node:async_hooks";
                                           ~~~~~~~~~~~~~~~~~~

  The package "node:async_hooks" wasn't found on the file system but is built into node. Are you
  trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this
  error.

error: Uncaught (in promise) Error: Build failed with 1 error:
node_modules/@langchain/langgraph/dist/setup/async_local_storage.js:2:34: ERROR: Could not resolve "node:async_hooks"

I've attached a minimal code snippet to reproduce the issue:

agent.ts

import { Annotation } from 'npm:@langchain/langgraph';

const GraphState = Annotation.Root({
  messages: Annotation<any[]>({
    reducer: (x, y) => x.concat(y),
    default: () => [],
  }),
});

build.ts :

import * as esbuild from 'npm:esbuild';

import { denoPlugins } from 'jsr:@luca/esbuild-deno-loader@^0.11.1';

const result = await esbuild.build({
  plugins: [...denoPlugins({ loader: 'native' })],
  entryPoints: ['test.ts'],
  outfile: './dist/test.esm.js',
  bundle: true,
  minify: true,
  format: 'esm',
});

console.log(result.outputFiles);

esbuild.stop();

command to run this error:
deno run --allow-all build.ts

Originally created by @mrfy on GitHub (Mar 25, 2025). I have a Deno project where I want to use LangGraph. However, during the build process (I'm using esbuild), I encounter the following error: ```js ✘ [ERROR] Could not resolve "node:async_hooks" node_modules/@langchain/langgraph/dist/setup/async_local_storage.js:2:34: 2 │ import { AsyncLocalStorage } from "node:async_hooks"; ╵ ~~~~~~~~~~~~~~~~~~ The package "node:async_hooks" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error. error: Uncaught (in promise) Error: Build failed with 1 error: node_modules/@langchain/langgraph/dist/setup/async_local_storage.js:2:34: ERROR: Could not resolve "node:async_hooks" ``` I've attached a minimal code snippet to reproduce the issue: **agent.ts** ```ts import { Annotation } from 'npm:@langchain/langgraph'; const GraphState = Annotation.Root({ messages: Annotation<any[]>({ reducer: (x, y) => x.concat(y), default: () => [], }), }); ``` **build.ts** : ```ts import * as esbuild from 'npm:esbuild'; import { denoPlugins } from 'jsr:@luca/esbuild-deno-loader@^0.11.1'; const result = await esbuild.build({ plugins: [...denoPlugins({ loader: 'native' })], entryPoints: ['test.ts'], outfile: './dist/test.esm.js', bundle: true, minify: true, format: 'esm', }); console.log(result.outputFiles); esbuild.stop(); ``` command to run this error: `deno run --allow-all build.ts `
yindo closed this issue 2026-02-15 17:17:26 -05:00
Author
Owner

@benjamincburns commented on GitHub (Mar 25, 2025):

This is expected behavior.

Are you bundling for node or the web? If the prior, add platform: node to your config. If the latter, make sure that you're only importing from @langchain/langgraph/web in your app.

@benjamincburns commented on GitHub (Mar 25, 2025): This is expected behavior. Are you bundling for node or the web? If the prior, add `platform: node` to your config. If the latter, make sure that you're only importing from `@langchain/langgraph/web` in your app.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#215