Skip to content

Playground does not respect 'use node' directive #173

@DennisKraaijeveld

Description

@DennisKraaijeveld

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions