Not being able to import node:crypto

We are trying to deploy a worker that needs Node.js’ crypto package. Following the docs, we tried doing:

import crypto from "node:crypto"

But we got the same error as in this issue: 🐛 BUG: Uncaught Error: Dynamic require of "node:crypto" is not supported · Issue #4725 · cloudflare/workers-sdk · GitHub

Using browserify-crypto created other problems such as crypto.subtle is undefined.

What’s the right way to import node:crypto in the Cloudflare’s workers?

2 Likes