workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

🐛 BUG: Dynamic require of "node:crypto" is not supported

Open dmotz opened this issue 4 months ago • 0 comments

Which Cloudflare product(s) does this pertain to?

Workers Runtime

What version(s) of the tool(s) are you using?

3.29.0 [Wrangler]

What version of Node are you using?

20.10.0

What operating system and version are you using?

macOS 14.3

Describe the Bug

Observed behavior

I am trying to use an npm package which internally uses Node's crypto module. The module imports it like this:

const crypto = require("node:crypto");

I receive this error when running the worker locally:

Uncaught Error: Dynamic require of "node:crypto" is not supported

I've tried adding this flag to my toml config, but it still fails:

compatibility_flags = [ "nodejs_compat" ]

Expected behavior

Workers should support modules that require node:crypto.

Steps to reproduce

Import a module that requires node:crypto.

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

dmotz avatar Feb 25 '24 01:02 dmotz