Error: Digest method not supported

I want use node:crypto module

So i followed this doc
https://developers.cloudflare.com/workers/runtime-apis/nodejs/#:~:text=Log%20in%20to%20the%20Cloudflare%20dashboard%20and%20select,compatibility%20flag%20to%20your%20Preview%20and%20Production%20deployments.

I added compatibility_flags = ['nodejs_compat'] in wrangler.toml

and code:
import crypto from 'node:crypto'
hash = crypto.createHash(method)
hash.update(date); hash.update(email)
const hdateemail = hash.digest(encoding)
console.log(hdateemail)

It works perfectly when use 'npm run dev'
but when use 'npx wrangler dev', it not works
Error: Digest method not supported

ps.
I also added flags on cli like 'npx wrangler dev --compatibility_flags nodejs_compat' and not works at all..
image.png
Implemented Node.js runtime APIs and enablement instructions for your Worker project.
Was this page helpful?