dannyelo
dannyelo4mo ago

[ERROR] Could not resolve "node:async_hooks"

Hello, I have this error when trying to run npx convex dev Any idea?
⠦ Preparing Convex functions...
✘ [ERROR] Could not resolve "node:async_hooks"

node_modules/@clerk/nextjs/dist/esm/server/clerkMiddleware.js:1:34:
1 │ 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.
⠦ Preparing Convex functions...
✘ [ERROR] Could not resolve "node:async_hooks"

node_modules/@clerk/nextjs/dist/esm/server/clerkMiddleware.js:1:34:
1 │ 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.
2 Replies
dannyelo
dannyeloOP4mo ago
This errors happens after invoking currentUser from clerk server. import { currentUser } from '@clerk/nextjs/server' And using it inside a convex query function. const user = await currentUser()
ballingt
ballingt4mo ago
It looks like a Convex function is trying to import @clerk/nextjs code, which doesn't work. You'll need to track down which files this is and not import code that can't run in the Convex environment in convex files.

Did you find this page helpful?