Quickstart fails with "Top-level await currently not supported" error #128

Closed
opened 2026-02-15 17:16:02 -05:00 by yindo · 2 comments
Owner

Originally created by @stringbeans on GitHub (Oct 31, 2024).

While following the quickstart guide here:

https://langchain-ai.github.io/langgraphjs/tutorials/quickstart/#making-your-first-agent-using-langgraph

Following the guide exactly, and using Node v22.9.0, I get the following error after running npx tsx agent.ts:

node:internal/modules/run_main:123
    triggerUncaughtException(
    ^
Error: Transform failed with 2 errors:
/home/john/Development/langgraph-agent/agent.ts:26:24: ERROR: Top-level await is currently not supported with the "cjs" output format
/home/john/Development/langgraph-agent/agent.ts:35:23: ERROR: Top-level await is currently not supported with the "cjs" output format
    at failureErrorWithLog (/home/john/Development/langgraph-agent/node_modules/esbuild/lib/main.js:1476:15)
    at /home/john/Development/langgraph-agent/node_modules/esbuild/lib/main.js:755:50
    at responseCallbacks.<computed> (/home/john/Development/langgraph-agent/node_modules/esbuild/lib/main.js:622:9)
    at handleIncomingPacket (/home/john/Development/langgraph-agent/node_modules/esbuild/lib/main.js:677:12)
    at Socket.readFromStdout (/home/john/Development/langgraph-agent/node_modules/esbuild/lib/main.js:600:7)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
    at Readable.push (node:internal/streams/readable:392:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:189:23) {
  name: 'TransformError'
}

Node.js v22.9.0

The error is simple to fix by restructuring the code to not use top-level awaits, but yeah... in the current state its not working if a user follows the examples as-is.

Originally created by @stringbeans on GitHub (Oct 31, 2024). While following the quickstart guide here: https://langchain-ai.github.io/langgraphjs/tutorials/quickstart/#making-your-first-agent-using-langgraph Following the guide exactly, and using Node v22.9.0, I get the following error after running `npx tsx agent.ts`: ``` node:internal/modules/run_main:123 triggerUncaughtException( ^ Error: Transform failed with 2 errors: /home/john/Development/langgraph-agent/agent.ts:26:24: ERROR: Top-level await is currently not supported with the "cjs" output format /home/john/Development/langgraph-agent/agent.ts:35:23: ERROR: Top-level await is currently not supported with the "cjs" output format at failureErrorWithLog (/home/john/Development/langgraph-agent/node_modules/esbuild/lib/main.js:1476:15) at /home/john/Development/langgraph-agent/node_modules/esbuild/lib/main.js:755:50 at responseCallbacks.<computed> (/home/john/Development/langgraph-agent/node_modules/esbuild/lib/main.js:622:9) at handleIncomingPacket (/home/john/Development/langgraph-agent/node_modules/esbuild/lib/main.js:677:12) at Socket.readFromStdout (/home/john/Development/langgraph-agent/node_modules/esbuild/lib/main.js:600:7) at Socket.emit (node:events:519:28) at addChunk (node:internal/streams/readable:561:12) at readableAddChunkPushByteMode (node:internal/streams/readable:512:3) at Readable.push (node:internal/streams/readable:392:5) at Pipe.onStreamRead (node:internal/stream_base_commons:189:23) { name: 'TransformError' } Node.js v22.9.0 ``` The error is simple to fix by restructuring the code to not use top-level awaits, but yeah... in the current state its not working if a user follows the examples as-is.
yindo closed this issue 2026-02-15 17:16:02 -05:00
Author
Owner

@jacoblee93 commented on GitHub (Nov 1, 2024):

Yeah, suppose we should specify .mts or say that you should use ESM, thanks for flagging

@jacoblee93 commented on GitHub (Nov 1, 2024): Yeah, suppose we should specify `.mts` or say that you should use ESM, thanks for flagging
Author
Owner

@dwabyick commented on GitHub (Nov 17, 2024):

I hit the same issue.

@dwabyick commented on GitHub (Nov 17, 2024): I hit the same issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#128