Dynamic require of "node:crypto" is not supported

compatibility_flags = [ "nodejs_compat" ]
var crypto = require("node:crypto");

log:

⎔ Starting local server...
[wrangler:inf] Ready on http://127.0.0.1:8787
X [ERROR] service core:user:my-worker: Uncaught Error: Dynamic require of "node:crypto" is not supported

    at null.<anonymous> (index.js:7:9)
    at null.<anonymous> (index.js:68:18) in src/AccessToken2.js
    at null.<anonymous> (index.js:13:50) in __require2
    at null.<anonymous> (index.js:624:36)

Hi there,

I would start by updating wrangler to the latest version.

The error suggest that you’re trying to dynamically import Node’s crypto module, but dynamic imports are not yet supported in Cloudflare workers.

Take care.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.