Next.js Discord

Discord Forum

Edge runtime node:crypto error in installed npm package

Unanswered
White-crowned Sparrow posted this in #help-forum
Open in Discord
White-crowned SparrowOP
The application handles routes. The API uses the npm package @tma.js/init-data-node, but it uses node:crypto. Then my API route handler sets the edge runtime. I can't change this package. How should I solve it so that it can run without errors in the edge runtime?
I have tried various configuration methods, but none of them seem to work.

9 Replies

"node:crypto" only works in normal runtime and not edge, so unless you can get the package to ue webcrypto or an alternative, you cant use edge sadly
also if i may ask, why do you have to use edge?
^aka webcrypto
and as OP didnt make the code, they should either use their package manager's patch option or fork and make own package using better apis
You can't use this package in edge runtime.
@riský also if i may ask, why do you have to use edge?
Reason is that he is using cloudflare pages
@"use php" Reason is that he is using cloudflare pages
the sad part is cloudflare workers does support it, just nextjs builder doesnt agree with the idea: https://developers.cloudflare.com/workers/runtime-apis/nodejs/crypto/