Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stringbeans opened this issue Oct 31, 2024 · 2 comments
Open

Comments

@stringbeans
Copy link

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.

@jacoblee93
Copy link
Collaborator

jacoblee93 commented Nov 1, 2024

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

@dwabyick
Copy link

I hit the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants