get-convex / get-convex/agent

Playground does not respect 'use node' directive

Open
#173 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
349
Forks
92
Avg merge
3d 10h
Merged PRs (30d)
24

Description

Hi,

When defining agents inside `definePlaygroundAPI` that uses `'use node'`, deployment to the hosted Playground version fails.

```
✘ [ERROR] Could not resolve "node:crypto"

convex/lib/email.helpers.ts:10:27:
10 │ import { createHash } from "node:crypto";
╵ ~~~~~~~~~~~~~

The package "node:crypto" 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.

It looks like you are using Node APIs from a file without the "use node" directive.
Split out actions using Node.js APIs like this into a new file only containing actions that uses "use node" so these actions will run in a Node.js environment.
For more information see https://docs.convex.dev/functions/runtimes#nodejs-runtime
```

These errors won't happen when deploying the code to Convex itself.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.